php Mail() and Outlook


php Mail() and Outlook

我有以下代码:

    $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);

然而,当我把电子邮件发给自己时,我会在Outlook中看到所有的代码。如果我把它发给其他人,他们会看到HTML。如果我把它发送到我的hotmail,他们会看到HTML。

这是我的展望(2007)的问题吗?如果是,是什么问题?或者我可以在电子邮件中做些什么来保证它正确显示吗?

请帮忙!

我发现了问题:

Godaddy基于web的邮件的HTML电子邮件未正确显示

更改:

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

至:

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

谢谢你们的帮助!:)

尝试重新排序标头。我记得不久前也遇到过同样的问题,在我使用以下标题后,它就起了作用:

    $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";

不过,我建议使用一个现成的php mailer类——这会让生活变得更轻松。

听起来您的outlook设置为以纯文本显示消息,无论消息以何种格式发送。

进入outlook prefs并将其更改为以消息到达的格式查看消息。