Does anyone know how I can get around this? Is my mime message "malformed"? The code that I am using is below.
Code: Select all
$to = "person@website.com";
$msg = "Here is my message content.";
$boundary = md5(time());
$header = "From: address@website.com <address@website.com>\n" .
"Reply-to: address@website.com <address@website.com>\n" .
"Return-path: address@website.com <address@website.com>\n" .
"X-Priority: 1 (High)\n" .
"X-Mailer: PHP/" . phpversion() . "\n" .
"MIME-Version: 1.0\n" .
"Content-Type: multipart/mixed; boundary=\"$boundary\"\n\n";
$body = "--$boundary\n";
$body.= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$body.= "Content-Transfer-Encoding: 7bit;\n\n";
$body.= "" . preg_replace("/\r\n/i", "\n", "<font face=\"Arial\" size=\"2\">$msg</font>") . "\n\n";
$body.= "--$boundary\n";
$body.= "Content-Type: application/octet-stream\n";
$body.= "Content-Transfer-Encoding: base64\n";
$body.= "Content-Disposition: attachment; filename=\"filename.pdf\"\n\n";
set_magic_quotes_runtime(0);
$attachment = fread(fopen("/home/user/public_html/pdf_temp/filename.pdf", "rb"), filesize("/home/user/public_html/pdf_temp/filename.pdf"));
$attachment = chunk_split(base64_encode($attachment));
$attachment = preg_replace("/\r\n/i", "\n", $attachment);
$body.= $attachment . "\n";
mail($to, $subject, $body, $header);