下面的代码是正确发送电子邮件,但身体。我需要在消息正文中显示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>");
}
?>
呼如林
手掌心
杨__羊羊