Your Open Source
Free YourOpenSource Softwares Online Resources and Softwares Downloads with Demo
Related Links
PHP
How to send mails with attachment in php
How to send mails with attachment in php :- You can send the email with attachment using PHP mail() function.
14403
Jul 08 08 04:23:20
Sekar
| PHP Mail |
The php mail with attachement code as follows |
<?php
$random_hash = md5(date('r', time())); $subject = "Attachement Mail in PHP"; $message = "You can attach the files with e-mail in PHP mail function'; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\""; /* additional headers */ $headers .= "To: phpkit <admin@phpkit.in>\r\n"; $headers .= "From: Sam <sam@phpkit.in>\r\n"; $attachment = chunk_split(base64_encode(file_get_contents('attachment_files.zip'))); $headers . ='Content-Type: multipart/alternative; boundary="==Multipart_Boundary_x{'.$random_hash.')'; $mail_content .= "This is a multi-part message in MIME format.\n\n" . "--Multipart_Boundary_x{{$random_hash})\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; "--Multipart_Boundary_x{{$random_hash})\n Content-Type: application/zip; name=\"attachment.zip\" Content-Transfer-Encoding: base64 \n\n Content-Disposition: attachment \n\n ".$attachment."\n\n". "--Multipart_Boundary_x{{$random_hash})--\n"; /* and now mail it */ mail("admin@phpkit.in", $subject, $mail_content, $headers); ?> |
Rating : 









|
|||||
Digg
Yahoo
delicious