Anyone Can Code

Not everyone is a coder, but a coder can come from anywhere

HTML mail doesn’t show in Microsoft Outlook

Posted by jhalak on July 25, 2008

I have sent HTML mail with PHP but it shows in evolution / thunderbird in Linux but not in Outlook Express in Windows. To solve the problem use the following code:

$boundary = “_e5YKJHKJHKH098090871893712893″;
$message = “–$boundary\n”;
$message .= “Content-disposition: inline\n”;
$message .= “Content-type: text/html\n\n”;
$message .= “<html>\n”;
$message .= “<head>\n”;
$message .= “<title>Your title</title>\n”;
$message .= “</head>\n”;
$message .= “<body>\n”;
$message .= “\n”;
$message .= “<TABLE width=600 border=0 cellpadding=4 cellspacing=1 bgcolor=#878676>\n”;
$message .= “    <TR>\n”;
$message .= “        <TD bgcolor=white nowrap>Your text</TD>\n”;
$message .= “    </tr>\n”;
$message .= “</TABLE>\n”;
$message .= “</body>\n”;
$message .= “</html>\n”;
$message .= “\n–$boundary–\n”;
$headers = ‘From:’ .$author. “\r\n” . ‘Reply-To:’ .$author;
$headers .= “\nContent-type: multipart/alternative; boundary=\”$boundary\”\nMime-Version: 1.0″;

if (mail($mailto, $subject , $message, $headers)) echo “Mail sent successfully”;

else echo “Something problem !!!!!!!!!!!!!!!!”;

2 Responses to “HTML mail doesn’t show in Microsoft Outlook”

  1. Tommy said

    What part of this was the solution?

  2. jhalak said

    Sorry. I should make it clear.
    Actually this should be at the first and at the last part of the message.

    Thanks for your comment Tommy.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>