Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding line breaks to a text/plain email

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:

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?

like image 724
Chuck Le Butt Avatar asked Mar 08 '12 14:03

Chuck Le Butt


People also ask

How do I add a new line in plain text?

You must be using double quotes, and you use \r\n to make a new line.

How do you insert a new line in an email?

%0d%0a is the new line symbol of the email body in a mailto link.

Why is Outlook stripping line breaks from plain text emails?

Reason. By default, the Remove extra line breaks in plain text messages option is enabled in Outlook. So, if a line break is found, it is removed (but, if there are two or more successive line breaks, they are not removed).

How do I add a line in HTML email?

In the most basic way you can Just press Ctrl + Enter when typing out the email, e.g. If you are needing something more complex, then you can Generate the email using a hidden HtmlText Box. If you are comfortable with HTML. You can then add a <br/> tag to allow a new line.


2 Answers

use double quotes like this

->setBody("Did you request a password reset for your account?\r\n\r\nIf yes, click here:\r\nhttp://www.website.com", 'text/plain'); 
like image 112
silly Avatar answered Sep 21 '22 15:09

silly


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'); 
like image 34
jprofitt Avatar answered Sep 23 '22 15:09

jprofitt