如何使用PHP发送的HTML构建电子邮件正文格式

如何使用PHP发送的HTML构建电子邮件正文格式,php,html,Php,Html,试图了解如何自定义使用PHP发送的电子邮件。我相信它应该用basic和表来完成。我在$message区域做错了什么 到目前为止,我在我的信息区中看到: <html><body><h1>Hello, World!</h1></body></html> 你好,世界! 这是我的密码: <?php session_start(); require_once('payflow.php'); $tranid =

试图了解如何自定义使用PHP发送的电子邮件。我相信它应该用basic
和表来完成。我在
$message
区域做错了什么

到目前为止,我在我的信息区中看到:

<html><body><h1>Hello, World!</h1></body></html>
你好,世界!
这是我的密码:

<?php
  session_start();
  require_once('payflow.php');

  $tranid  = $_GET['PNREF'];
  $email   = $_GET['EMAIL'];
  $billtofirstname = $_GET['BILLTOFIRSTNAME'];
  $billtolastname = $_GET['BILLTOLASTNAME'];
  $billtoname = $_GET['BILLTONAME'];
  $billtostreet = $_GET['BILLTOSTREET'];
  $billtostreet2 = $_GET['BILLTOSTREET2'];
  $billtocity = $_GET['BILLTOCITY'];
  $billtostate = $_GET['BILLTOSTATE'];
  $billtozip = $_GET['BILLTOZIP'];

  $to = $email;
  $subject = "ORDER #$tranid\n";
  $headers = "From: $email\n";

  $message = '<html><body>';
  $message .= '<h1>Hello, World!</h1>';
  $message .= '</body></html>';

  mail($to,$subject,$message,$headers);

?>

电子邮件工作正常,
$\u获取的数据很好。只是对如何让消息区域按照php文档阅读感到困惑

<?php
// Multiple recipients
$to = 'johny@example.com, sally@example.com'; // note the comma

// 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>Johny</td><td>10th</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';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';

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

// Mail it
mail($to, $subject, $message, implode("\r\n", $headers));
?>


这篇文章写得很好……谢谢你,埃普看到了。我遗漏了两个标题“MIME”和“内容类型”-谢谢