Page 1 of 1

Mail sent from mail() blocked by MailMarshall

Posted: Wed Jun 04, 2008 9:41 am
by icesolid
I have a simple script that sends out a message with an attachment using mail(). ALL of the people that I send mail to using this function recieve the messages without any issues. However, there is one person that does NOT recieve the messages and the company is using MailMarshall. The messages that I send go into a folder on their mail server called "malformedmime".

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);

Re: Mail sent from mail() blocked by MailMarshall

Posted: Wed Jun 04, 2008 11:12 am
by panic!

Re: Mail sent from mail() blocked by MailMarshall

Posted: Wed Jun 04, 2008 1:01 pm
by RobertGonzalez
PHP Mailer blows hard. Use Swiftmailer. It is faster, more efficient, more supported and was written by our very own Chris Corbyn.