Php HTML格式的电子邮件无法正确显示

Php HTML格式的电子邮件无法正确显示,php,Php,我仍然在努力处理这个邮件脚本——我现在正在通过所有标记的html,而不是将其视为呈现的html,如果这有意义的话 <?php $mailheader .= "MIME-Version: 1.0\r\n"; $mailHeader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $formcontent .="<table border='1'>"; foreach ($_POST as $field=>$valu

我仍然在努力处理这个邮件脚本——我现在正在通过所有标记的html,而不是将其视为呈现的html,如果这有意义的话

<?php
$mailheader .= "MIME-Version: 1.0\r\n";
$mailHeader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$formcontent .="<table border='1'>";
foreach ($_POST as $field=>$value)
{
    $formcontent.="<tr>";
    $formcontent .= "<td>$field:</td> <td>$value</td>";
    $formcontent.="</tr>";
}
$formcontent .= '<tr><td>User-Agent: </td><td>'.$_SERVER['HTTP_USER_AGENT'].'</td>';
$formcontent .="</table>";


$recipient = "info@*******.com";
$subject = "Event feedback form";
$mailheader = "From: web.form@*******-events.co.uk\r\n";
$mailheader .= "Reply-To: $email\r\n";
$mailHeader .= "Content-type: text/html; charset=iso-8859-1\r\n";


mail($recipient, $subject, $formcontent, $mailheader) or die("Failure!");
header("location:http://www.******-events.co.uk");
?>


我宁愿使用PHP类作为HTML电子邮件的PHP编译器。顺便说一句,我将为邮件正文添加完整的HTML文档标记(HTML、head、body等)

遵循php文档:

你需要html标签

 <?php
// multiple recipients
$to  = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';

// subject
$subject = 'Birthday Reminders for August';

// message
$message = '
<html>
<head>
  <title>Birthday Reminders for August</title>
</head>
<body>
  <p>Here are the birthdays upcoming in August!</p>
  <table>
    <tr>
      <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
    </tr>
    <tr>
      <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
    </tr>
    <tr>
      <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
    </tr>
  </table>
</body>
</html>
';

// 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";

// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
?>

我错过了这些:

$formcontent = '<html><body>';
$formcontent='';
谢谢大家的时间和投入
吉姆

你是如何打开这一页的?是否将其拖到浏览器窗口上/通过文件打开?或者您正在使用localhost/index.php浏览它?(假设你现在在本地托管)这就是问题所在-我把所有的标题都放进去了,但电子邮件表单仍然返回这样的信息:Company::test td>Contact::jim holmesEmail::testDate::221122事件前支持是否彻底?:5足够的事件前支持?:5良好的沟通?:5等等,你明白了。。为什么电子邮件客户端不呈现html?它并不是说你把它们放在php文件中。你认为它们包括在哪里?前三行?这可不是一回事。尝试以与示例相同的方式执行此操作。将html标记放在消息字符串中。但是我的脚本中没有消息字符串?这是来自一个在线表单,我想格式化成一个表-如果我粘贴到一个html文档的html结果很好-只是不在电子邮件客户端!