multipart email not showing in hotmail

the mail() function

Moderators: macek, egami, gesf

amanank
New php-forum User
New php-forum User
Posts: 1
Joined: Thu May 12, 2011 12:24 am

multipart email not showing in hotmail

Postby amanank » Thu May 12, 2011 1:37 am

I had an issue with hotmail showing blank message when email sent with multipart content type. After 6 hours of trials it turned out to be carriage returns causing the problem

A simple search and replace fixed the issue

Code: Select all

$body = str_replace("\r", '', $body);


Code: Select all

<?php
$notice_text = "This is a multi-part message in MIME format.";
$plain_text = "This is a plain text email.\r\nIt is very cool.";
$html_text = '<html><body><h2>heading</h2><p>paragraph <b>text</b>.</p></body></html>';

$semi_rand = md5(time());
$mime_boundary = "==MULTIPART_BOUNDARY_$semi_rand";
$mime_boundary_header = chr(34) . $mime_boundary . chr(34);

$to = "hotmailsucks@hotmail.com";
$bcc = "";
$from = "Me.com <me@me.com>";
$subject = "My Email";

$body = "$notice_text

--$mime_boundary
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

$plain_text

--$mime_boundary
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

$html_text

--$mime_boundary--";

$body = str_replace("\r", '', $body);

if (@mail($to, $subject, $body,
    "From: " . $from . "\n" .
    "MIME-Version: 1.0\n" .
    "Content-Type: multipart/alternative;\n" .
    "     boundary=" . $mime_boundary_header))
    echo "Email sent successfully.";
else
    echo "Email NOT sent successfully!";
?>

Return to “PHP coding => Mail”

Who is online

Users browsing this forum: No registered users and 1 guest