Mail sent from mail() blocked by MailMarshall

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Mail sent from mail() blocked by MailMarshall

Post 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);
User avatar
panic!
Forum Regular
Posts: 516
Joined: Mon Jul 31, 2006 7:59 am
Location: Brighton, UK

Re: Mail sent from mail() blocked by MailMarshall

Post by panic! »

User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Mail sent from mail() blocked by MailMarshall

Post by RobertGonzalez »

PHP Mailer blows hard. Use Swiftmailer. It is faster, more efficient, more supported and was written by our very own Chris Corbyn.
Post Reply