2012-04-02 79 views
2
$message = 'New user registration\n\n 
There is a new submission on the site and below are the details.\n\n'; 

我试图使用html,但它显示电子邮件中的文本,所以我将其更改为纯文本。仍然不能换行。电子邮件 - 在电子邮件中做新行的正确方法是什么?

我不知道为什么它不能按我的想法工作。

编辑#2

$umessage .= '<a href="'.$pdflink.'">Download Brochure</a>'; 

的问题是,它显示在电子邮件:Download Brochure

有周围没有任何办法吗?

回答

5

当您使用单引号字符串时,不会解释换行符。你需要使用"来封装你的字符串。

此外,您应该使用\r\n与邮件客户端兼容。

$message = "New user registration\r\n 
There is a new submission on the site and below are the details.\r\n"; 
+0

有没有办法绕过href链接? – joe 2012-04-02 05:57:15

+0

请创建一个新问题。你应该问每个职位一个问题。 – 2012-04-02 06:42:37

+0

“当您使用单引号字符串时,不会解释换行符。”这是重要的。感谢你的回答。 – 2017-11-02 07:22:35

3

尝试使用“\ r \ n”作为换行符。

$message = 'New user registration\r\n 
There is a new submission on the site and below are the details.\r\n'; 
+0

感谢您的快速回复。你帮了!有效。 – joe 2012-04-02 05:07:03

+0

使用它两次会破坏多条线吗? – joe 2012-04-02 05:11:16

+0

这是正确的。还请注意burhan的回答,他提出了一个关于使用包含换行符的字符串的双引号的好处。 – BluesRockAddict 2012-04-02 05:12:58

相关问题