下面的代码正确发送电子邮件,但是正文。我需要在邮件正文中显示html,但我无法做到。在网络中的示例将不会发送电子邮件:(Php mail:如何发送html?
如何解决我的代码与在体内的HTML发送电子邮件?
由于一吨!
<?php
$to = '[email protected]';
$subject = 'I need to show html';
$from ='[email protected]';
$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的问题,我有同样的问题,但这个线程的答案是(从不同的角度) – Sam 2011-03-30 01:55:58