/ Published in: PHP
Function to send HTML emails with an attachment in PHP. Notes and info at the above url!
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function mail_file( $to, $subject, $messagehtml, $from, $fileatt, $replyto="" ) { $fileatttype = ""; if ($ext == ".doc") $fileatttype = "application/msword"; if ($ext == ".jpg") $fileatttype = "image/jpeg"; if ($ext == ".gif") $fileatttype = "image/gif"; if ($ext == ".pdf") $fileatttype = "application/x-pdf"; if ($fileatttype=="") $fileatttype = "application/octet-stream"; $headers = "From: $from "; if ($replyto) $headers .= "Reply-To: ".$replyto." "; $headers .= "MIME-Version: 1.0 "; $headers .= "Content-Type: multipart/mixed; boundary=\"".$uid."\" "; $headers .= "This is a multi-part message in MIME format. "; $headers .= "--".$uid." "; $headers .= "Content-type:text/html; charset=iso-8859-1 "; $headers .= "Content-Transfer-Encoding: 7bit "; $headers .= $messagehtml." "; $headers .= "--".$uid." "; "; $headers .= "Content-Transfer-Encoding: base64 "; "; $headers .= $content." "; $headers .= "--".$uid."--"; ","\n",$headers) ) ; }
URL: http://www.barattalo.it/2010/01/10/sending-emails-with-attachment-and-html-with-php/