我有以下邮件功能:
<?php
{
$to = "alee@####.com";
$subject = "General Contact.";
$headers = "From: ####<noreply@####.com>\r\n";
$headers .= "Reply-To: info@####.com\r\n";
$headers .= "Return-Path: info@####.com\r\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$name = filter_input(INPUT_POST, 'name');
$telephone = filter_input(INPUT_POST, 'phone');
$nature = filter_input(INPUT_POST, 'nature');
$comments = filter_input(INPUT_POST, 'comments');
$message =
"<span style='font-weight: bold;'>Name: </span>"."<br />".$name."<br />"."<br />".
"<span style='font-weight: bold;'>Telephone: </span>"."<br />".$telephone."<br />"."<br />".
"<span style='font-weight: bold;'>Nature of enquiry: </span>"."<br />".$nature."<br />"."<br />".
"<span style='font-weight: bold;'>Comments: </span>"."<br />".$comments."<br />"."<br />";
mail($to, $subject,"We have received a message via the online form at www.####.com<br /> <br />" . $message, $headers);
echo "Your message was successfully sent. Please <a href='contact.php'>click here</a> to return to the site.";
?>
<?php }
?>
我的问题是,当使用表单并且邮件打到我的收件箱时,HTML被显示为纯文本,而不能正确显示。因此,我可以看到所有内联HTML元素,
即将会显示为段落的一部分,而不显示新行。任何帮助都是极好的!
编辑:
Reply-To: info@###.com
Return-Path: info@###.com
MIME-Version: 1.0
Content-type: text/html; charset: utf8
We have received a message via the online form at www.###.com<br /><br /><span style='font-weight: bold;'>Name: </span><br />Aaron Lee<br /><br /><span style='font-weight: bold;'>Telephone: </span><br />#####<br /><br /><span style='font-weight: bold;'>Nature of enquiry: </span><br />###<br /><br /><span style='font-weight: bold;'>Comments: </span><br />Testttttttttttt<br /><br />
尝试替换以下行:
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
与:
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset: utf8\r\n";
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句