Archive for the ‘PHPMailer’ Category

PHPMailer & Hotmail showing an empty or blank screen

Tuesday, July 27th, 2010

Yes, as it reads.

I’ve been using PHPMailer class for a while but only a few days from now I received a complaint from a customer that told me he got an empty email with his order confirmation.

At first I assumed he was the only one experiencing this so I told him to tweek his Hotmail account or move to Gmail, Yahoo or a better service provider. Next thing I knew a couple more customers sent me an email with the same complain.

So, it’s only happening with Hotmail… Time to do some tests.

To my surprise email was arriving to destination address but it was showing nothing, it was a blank/empty email body. No way! somethings gotta be wrong! I right clicked the message and selected the view source option.

Ok, message content was there so something else is happening. Email headers, boundaries… something is causing the email not to be shown.

After a couple of days of searching and testing I came to this simple solution.

Go to phpmailer.class.php

Then search for code lines that look like this:

$result = ”;

switch ($this->message_type) {

case ‘plain’ :

$result .= $this->HeaderLine ( ‘Content-Transfer-Encoding’, $this->Encoding );

$result .= sprintf ( “Content-Type: %s; charset=\”%s\””, $this->ContentType, $this->CharSet );

break;

case ‘attachments’ :

case ‘alt_attachments’ :

if ($this->InlineImageExists ()) {

$result .= sprintf ( “Content-Type: %s;%s\ttype=\”text/html\”;%s\tboundary=\”%s\”%s”, ‘multipart/related’, $this->LE, $this->LE, $this->boundary [1], $this->LE );

} else {

$result .= $this->HeaderLine ( ‘Content-Type’, ‘multipart/mixed;’ );

$result .= $this->TextLine ( “\tboundary=\”” . $this->boundary [1] . ‘”‘ );

}

break;

case ‘alt’ :

$result .= $this->HeaderLine ( ‘Content-Type’, ‘multipart/alternative;’ );

$result .= $this->TextLine ( “\tboundary=\”” . $this->boundary [1] . ‘”‘ );

break;

}

Do you see the line where it reads: multipart/alternative

Change that into multipart/mixed

That’s it! Hotmail will display your AltBody content!

It worked for us so if it doesn´t work for you, then better start messing with the headers 😀