Send Email with Attachment


$to = '';
$subject = 'This is the subject';
$headers = "From:\r\nReply-To:\r\n"
    . "Content-Type: multipart/alternative; boundary=\"1234567890\"";

$attachment = chunk_split(base64_encode(file_get_contents('')));

$message = 
Content-Type: multipart/alternative; boundary=\"abcdefghij\"

Content-Type: text/plain; charset=\"iso-8859-1\"
Content-Transfer-Encoding: 7bit

This is the text version of the message. 

Content-Type: text/html; charset=\"iso-8859-1\"
Content-Transfer-Encoding: 7bit

<div>This is the html version of the message.</div>


Content-Type: application/zip; name=\"\" 
Content-Transfer-Encoding: base64 
Content-Disposition: attachment 

" . $attachment . "

mail($to, $subject, $message, $headers);



Related Snippets

•  Send Email with utf-8 characters on the subject
•  HTTP Headers to Download a File
•  Set time limit indefinitely
•  Send Email in Html and Plain Text formats
•  Send Email in Html format
•  Send Email with CC and BCC