在邮件正文中显示新行

时间:2016-06-30 10:31:51

标签: php html email

我想在邮件正文段落中添加新行。我搜索了所有其他相同的问题,但似乎没有一行能够正常工作

$body = "Dear $surname  $name \r\n
Thank you for your Pre-registration for Global .\r\n
Please print the attached e-ticket with your personal barcode and bring it to the reception of the exhibition.\r\n
This barcode includes data about you which is required during registration. Having this barcode will considerably speed up the registration process
Organizing committee.\r\n".



$body = "Print e-ticket
              ($imageurl) .\r\n".

此方法在一行中显示全部 如何更改它才能正确显示? 谢谢

2 个答案:

答案 0 :(得分:1)

如果您使用身体的html格式,则必须使用<br>代替\r\n

ps:你有两次$body = ....所以你的第二个会覆盖第一个

答案 1 :(得分:1)

您只需在 while 功能中设置<br> 内容类型标头即可使用text/html

像这样,

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

您需要将 mail()功能的headers设置为第四个参数。

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

还可以使用.附加字符串。

像这样,

$body .= "Print e-ticket
              ($imageurl) \r\n".

mail()