我有以下邮件功能:
<?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 />