【发布时间】:2015-01-29 13:01:42
【问题描述】:
我在这个网站和 php.net 网站上查找了我应该使用我的 php mail() 函数发送哪些标签才能正确发送 html 邮件。不知何故,我的 gmail 仍然显示 html 标签。我在这方面做错了什么?
$to = "$email";
$subject = "order placed";
$from = "noreply@snorgytees.tk";
$message = "
Hi, '{$_SESSION['naam']}';
<html>
<head>
</head>
<body>
<table>
<tr>
<td>$Artikelnaam></td>
<td>$maat</td>
<td>$hoeveelheid</td>
<td>$$echteprijs</td>
<td>Total: $$totaalprijs;
<br><br>Total including VAT: $$prijs_btw</td>
</tr>
</table>
</body>
</html>
";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: $_POST["email"]' . "\r\n";
$headers .= 'From: noreply@snorgytees.tk' . "\r\n";
mail($to, $subject, $from, $message, $headers);
【问题讨论】:
-
<html>之前的最重要的文本使其无效。使用查看源代码查看 Gmail 收到的内容。然后停止使用mail()函数。使用 PHPMailer/SwiftMailer。这也将迫使您修复未解析的 $_POST 电子邮件地址。 -
您还需要删除
$headers .= 'To: $_POST["email"]' . "\r\n";,因为mail()中的第一个参数是“To:”