Php Mail () and Outlook

I have the following code:

    $subject = "Test Email";
    $from = "noreply@bob.com";
    ini_set("sendmail_from", $from);
$message = "<html><body bgcolor=\"#DCEEFC\"> 
                Hello<br><br>
                This is a <b>test</b> email.
                <br><br><hr>
                <a href=\"\">Click Here</a>     
                <br><br><hr>
                <br><br>
                Thank you for your time,<br><br>
            </body></html>";

    $headers  = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html\r\n"; 
    $headers .= "From: " . $from . "\r\n";
    mail($mail, $subject, $message, $headers);

However, when I send an email to myself, I see all the code in Outlook. If I send it to someone else, they see HTML. If I send it to my hotmail, they see the HTML.

Is this a problem for my Outlook (2007), if so, what is it, or can I do something in the letter to ensure that it displays correctly?

Please, help!

+5
source share
3 answers

I found the problem:

HTML email does not display correctly for Godaddy email

Modified by:

$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html\r\n"; 
$headers .= "From: " . $from . "\r\n";

at

$headers  = "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Content-Type: text/html; charset=ISO-8859-1" . PHP_EOL;
$headers .= "From: Site<$from>" . PHP_EOL;

Thank you all for your help! :)

+6
source

It looks like you have configured your appearance to display messages in plain text, regardless of the format in which they are sent.

, , .

+1

Try reordering the title. I remember that I had the same problem a while ago, and it worked after I used the following headers:

    $headers = "From: " .$from. "\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n";
    $headers .= "Content-Transfer-Encoding: 8bit\r\n";

I would recommend using a ready-to-use php zip class - this makes life easier.

+1
source

All Articles