2

我仍在为这个邮件脚本而苦苦挣扎 - 我现在正在通过所有标记的 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");
?>
4

3 回答 3

1

遵循 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);
?>
于 2012-06-19T21:04:32.363 回答
0

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

于 2012-06-19T21:04:02.897 回答
0

我错过了这些:

$formcontent = '<html><body>';

感谢大家的时间和投入,虽然吉姆

于 2012-06-20T20:08:47.820 回答