在文本/纯电子邮件中添加换行符


Adding line breaks to a text/plain email

我在发送plain text(而不是HTML!)电子邮件时遇到问题,我的所有换行符都被忽略:

->setBody('Did you request a password reset for your account?'r'n'r'nIf yes, click here:'r'nhttp://www.website.com', 'text/plain');

以上内容在电子邮件中显示为:

您是否请求重置帐户密码?''''r''n''r''n如果是,单击此处:''nhttp://www.website.com

我已经检查过了,标题显然设置正确:

Content-Type: text/plain; charset=utf-8

有人有这方面的经验吗?

使用类似的双引号

->setBody("Did you request a password reset for your account?'r'n'r'nIf yes, click here:'r'nhttp://www.website.com", 'text/plain');

您使用的是文字字符串。如果要添加换行符,请使用双引号而不是单引号。

->setBody("Did you request a password reset for your account?'r'n'r'nIf yes, click here:'r'nhttp://www.website.com", 'text/plain');