php Mail() 和 Outlook

标签 php email 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。

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

请帮忙!

最佳答案

我发现了问题:

HTML Email not displaying correctly for Godaddy web based mail

更改:

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

感谢大家的帮助! :)

关于php Mail() 和 Outlook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11757937/

相关文章:

WHERE 子句 MySQL 中的 PHP 字符串变量

php - 语义错误和逻辑错误的区别

email - 在 Magento 的自定义模块中发送订单确认邮件

outlook - 如何使用 ical.net 创建 HTML 格式的 ICS 消息正文?

php - 将php页面中的数据保存到2个sql表中

PHP urlize 函数

c# - HTML 电子邮件 : Must you send an alternate plain text view as well?

javascript - AWS Lambda : Unable to import module 'mail' : No module named mail

excel - GetObject(, "Outlook.Application") 无法在 Outlook 打开时使用

Python - 通过 Outlook 2007/2010 和 win32com 发送 HTML 格式的电子邮件