在邮件正文中显示新行


Display new line in mail body

我想在邮件正文段落插入新行。我已经搜索了所有其他相同的问题,但似乎没有一个工作

$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".

此方法将所有内容显示在一行中如何更改它以正确显示它?谢谢你

如果你使用html格式,那么你必须使用<br>而不是'r'n

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

您可以通过在mail()函数中设置text/html Content-type header来使用<br>

,

$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".

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