Re: Mail function and hotmail
| From: | Ashley Sheridan | Date: | Wed, 10 Jun 2009 17:12:19 +0000 |
| Subject: | Re: Mail function and hotmail | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-293885@lists.php.net to get a copy of this message | ||
On Wed, 2009-06-10 at 12:59 -0400, Fernando G wrote:
> Hello,
>
> I am sending an html message with and embedded image using the following code:
>
> // Read message from html template
> $message = fread("template.html", filesize("template.html"));
>
> // I replace the values in $message that are necessary to
> // fill the tempalte
> ...
>
> // Generate a boundary string
> $rand_value = md5(time());
> $mime_boundary = "-----$rand_value";
>
> $headers = "MIME-Version: 1.0\r\n";
> $headers .= "From: Name <name@domain.com>\r\n";
> $headers .= "Reply-To: Name <name@domain.com>\r\n";
> $headers .= "Return-Path: name@domain.com\r\n";
> $headers .= "Organization: Name\r\n";
> $headers .= "X-Mailer: PHP's mail() Function\r\n";
> $headers .= "Content-Type: multipart/related; ";
> $headers .= "boundary=\"$mime_boundary\";
> type=\"text/html\"\r\n\r\n";
>
> $body = "This is a multi-part message in MIME format.\r\n";
> $body .= "--$mime_boundary\r\n";
> $body .= "Content-Type: text/html; charset=UTF-8\r\n";
> $body .= "Content-Transfer-Encoding: 7bit\r\n\r\n$message\r\n\r\n";
> $body .= "--$mime_boundary\r\n";
> $body .= "Content-Type: image/jpg\r\n";
> $body .= "Content-Transfer-Encoding: base64\r\n";
> $body .= "Content-ID: <ggtourslogo>\r\n\r\n";
> $body .= chunk_split(base64_encode(file_get_contents("./templates/emaillogo.jpg")));
> $body .= "--$mime_boundary--";
>
> return mail("email@domain.com", "Subject", $body, $headers);
>
> However when it is send to a hotmail.com address the message is received blank. It does work
> fine with Gmail, Yahoo mail, Outlook Express and Thunderbird.
>
> Your help is much appreciated.
>
> Fernando
>
> _________________________________________________________________
> We are your photos. Share us now with Windows Live Photos.
> http://go.microsoft.com/?linkid=9666047
As far as I'm aware, Hotmail blocks all images by default. Also, I've
seen Outlook choke on message with the \r\n line endings, could Hotmail
be doing that too?
Thanks
Ash
www.ashleysheridan.co.uk