【发布时间】:2011-06-21 07:10:04
【问题描述】:
下面的代码可以正确发送电子邮件,但要发送正文。我需要在邮件正文中显示 html,但我无法做到。网络中的示例不会发送电子邮件:(
如何修复我的代码以发送正文中包含 html 的电子邮件?
非常感谢!
<?php
$to = 'mymail@mail.com';
$subject = 'I need to show html';
$from ='example@example.com';
$body = '<p style=color:red;>This text should be red</p>';
ini_set("sendmail_from", $from);
$headers = "From: " . $from . "\r\nReply-To: " . $from . "";
$headers .= "Content-type: text/html\r\n";
if (mail($to, $subject, $body, $headers)) {
echo("<p>Sent</p>");
} else {
echo("<p>Error...</p>");
}
?>
【问题讨论】:
-
+1 for question 我有类似的问题,但这个帖子回答了它(从各个角度)
标签: php html email message sendmail