下面的代码可以正确地发送电子邮件,但是出现在正文中。我需要在邮件正文中显示HTML,但我无法做到。网络上的示例不会发送电子邮件 :(
如何修复我的代码以使用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>");
}
?>