2

如何在使用 php mail() 函数发送的电子邮件中输出主题中断 (<hr>)。在电子邮件中,它显示为 <hr> 本身,而不是主题中断。

4

2 回答 2

1

查看示例 4:

http://php.net/manual/en/function.mail.php

<?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);
?>
于 2013-03-05T22:27:06.917 回答
0

如果您想在使用 mail() 发送的电子邮件中使用 HTML,则必须添加一个 Content-type 标头以声明该电子邮件应被解析为 HTML。请参阅http://php.net/manual/en/function.mail.php中的示例 4

于 2013-03-05T22:29:19.760 回答