将换行符添加到文本/普通电子邮件 [英] Adding line breaks to a text/plain email

查看:125
本文介绍了将换行符添加到文本/普通电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

发送一个纯文本(而不是 HTML !)电子邮件发生问题,我所有的换行符被忽略:

I'm having a problem sending a plain text (not HTML!) email, all my line breaks are being ignored:

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

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

The above is being displayed in the email as:


您是否要求为您的帐户重设密码?\r\\\
\r\\\
I是是,
点击这里:\\\
http:// www。网站网站

Did you request a password reset for your account?\r\n\r\nIf yes, click here:\nhttp://www.website.com

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

I've checked and the header is apparently set correctly:

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

有没有人有这方面的经验?

Does anyone have any experience with this?

推荐答案

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

You are using literal strings. If you would like to add the line breaks, use double quotes instead of a single quote.

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

这篇关于将换行符添加到文本/普通电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆