Reputation: 14142
I have a the string like the following used within an email sent by my application:
$msg = "{$name} has submitted an email for review.\n\n You can preview the email here";
The \n doesn't appear within the email - any ideas why?
I am using PHPMailer (old I know..)
Upvotes: 0
Views: 268
Reputation: 1
There is a new issue with sending html email. Spamfilters strictly enforce the rfc5322 and do not accept any line length > 998 characters. See https://www.ietf.org/rfc/rfc5322.txt --> par 2.1.1 Adding a html br tag to a large html file does still result in a single text line.
The solution is to use a wrapper (yes even when sending html) like $message = wordwrap($message, 70);
In my case (sending large CSV-like datasets) I had to ensure that there were spaces in the html that allow for the wrap to work. There is no visual effect on the html result as shown by the email client.
Upvotes: 0
Reputation: 6822
The newline is not being showed because you probably make a html email.
Try adding $msg = nl2br($msg);
which turns the \n's to <br/>
Upvotes: 2
Reputation: 499
Instead of \n\n You can use <br/>
tag. Try this once. This may help you.
Upvotes: 2
Reputation: 38147
If your sending the email as HTML then you need to replace the \n
with <br>
Upvotes: 6