在邮件功能的新行上分隔字符串

时间:2013-10-25 16:47:59

标签: php

你好我在邮件函数中有这种变量,但是我想把字符串中的文本用不同的行分开:

$email_body = "Dear Client,

Text Title one

Text Title on a new line
";

电子邮件内的最终结果是新行内的每一行。 现在,当我执行时,一切都在同一行内:

mail($to,$email_subject,$email_body,$headers);  

2 个答案:

答案 0 :(得分:1)

只需添加nl2br PHP函数即可查看换行符,如下所示:

mail($to,$email_subject,nl2br($email_body),$headers);  

答案 1 :(得分:0)

您可以使用html和所需的inline css作为电子邮件模板。

$email_body = "<html><body>";

$email_body. = "Dear Client,</br>";

$email_body. = "Text Title one,</br>";

$email_body. = "Text Title on a new line,</br>";

$email_body. = "</body></html>";

mail($to,$email_subject,$email_body,$headers);