PHP

SEND ATTACHMENT PHP MAIL

1) MAIL HEADER

$boundary = md5(time()); $mailHead = implode("\r\n", [   "MIME-Version: 1.0",   'Content-Type: multipart/mixed;    boundary="' .$boundary.'"' ]);

2) MAIL BODY

$mailAttach = "FILE"; $mailBody = implode("\r\n", [   THE MESSAGE   "--$boundary",   "Content-type: text/html; charset=utf-8",   "",   "MAIL MESSAGE",     THE ATTACHMENT   "--$boundary",   'Content-Type: application/octet-stream;    name="'.basename($mailAttach).'"',   "Content-Transfer-Encoding: base64",   "Content-Disposition: attachment",   "",   chunk_split(base64_encode   (file_get_contents  ($mailAttach))),   "--$boundary--" ]);

3) MAIL SEND

echo mail("jon@doe.com", "Subject", $mailBody, $mailHead)   ? "OK" : "ERROR" ;