PHP New Line Break in Emails

PHP new line break in emails

Try \r\n in place of \n

The difference between \n and \r\n

It should be noted that this is applicable to line returns in emails. For other scenarios, please refer to rokjarc's answer.

Send email with line breaks using mail() in php

It's \r\n, as in backslash not forward slash.

Also you can try it like this:

$message = "

Hi!

This is one line.

And this is another.

Bye!
";

Add line breaks in mail function php

To add line break you need to add "\n", not '\n'

newline not working in PHP mail

Try to change your ' to " - php interprets a string inside single quotes as literals, whereas with quotes (") it will expand the \r\n to what you want.

More information: http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.single

New lines (\r\n) are not working in email body

You need to use a <br> because your Content-Type is text/html.

It works without the Content-Type header because then your e-mail will be interpreted as plain text. If you really want to use \n you should use Content-Type: text/plain but then you'll lose any markup.

Also check out similar question here.

the following mail does not produce line breaks with double quotes

In html mails, you should use <br /> to add a line break.

All html parsers will ignore \n line breaks in the code.

PHP line breaks in email form

it depends on whether you send the email as plain text or html. if you use plain text you can insert a new line character

echo "........" . "\n"

or if you use html you can use the <br> tag

You set your content-type to text/html. So you need to use <br> instead of "\r\n"

trim additional line breaks being added in email body from imap_open

You can remove all extra new lines by using preg_replace.

preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $your_email_body);


Related Topics



Leave a reply



Submit