1

我的脚本发送电子邮件,但它不呈现 html 标签。我不知道为什么不。

$email = $row['email'];

$mail_body = '<html>
<body>

<p>hello,'.$name.'</p>
<p>this is a testing email </p>
<hr />
<p>by server</p>
</body>
</html>';
$subject = "Better website";
$to = "$email";

$headers = "From: mailscript@hotmail.com\r\n";
$headers .= "Content-Type: text/html\r\n";

$mail_result = mail($to, $subject, $mail_body, $headers);
4

2 回答 2

2

尝试设置 mime 类型以及mail()的手册中所示

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
于 2012-04-04T17:22:49.593 回答
0

正如 Jrod 已经回答的那样,您需要添加标题

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

但我发现这个最近把我搞砸了,不得不把它评论出来:

$headers  = 'MIME-Version: 1.0' . "\r\n";
于 2012-04-27T23:05:20.027 回答