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?
You must be using double quotes, and you use \r\n to make a new line.
%0d%0a is the new line symbol of the email body in a mailto link.
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).
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.
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');
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');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With