我有以下代码:
$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/