Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在邮件正文中显示新行_Php_Html_Email - Fatal编程技术网

Php 在邮件正文中显示新行

Php 在邮件正文中显示新行,php,html,email,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 b

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

$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格式,则必须使用

而不是
\r\n


ps:您有两个
$body=..
,因此您的第二个将覆盖第一个您只需在函数中设置
文本/html
内容类型标题即可使用

像这样,

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$body .= "Print e-ticket
              ($imageurl) \r\n".
您需要将
邮件()的
标题设置为第四个参数

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

还可以使用
附加字符串

像这样,

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$body .= "Print e-ticket
              ($imageurl) \r\n".


您使用的是哪种内容类型?