-2

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

$email_body = "Dear Client,

Text Title one

Text Title on a new line
";

电子邮件中的最终结果应该是新行中的每一行。现在,当我执行时,所有内容都在同一行内:

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

2 回答 2

1

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

mail($to,$email_subject,nl2br($email_body),$headers);  
于 2013-10-25T16:50:03.263 回答
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);
于 2013-10-25T16:53:01.520 回答