Search code examples
phpemailline-breaks

PHP mail linebreaks


I have a php mail script that works just fine as long as I define the body text in a var like this:

$body = "Some text goes here\n\nSome other text goes here!";

When done like this the linebreaks "\n" works perfect in the mail.

Now I want to insert the body text in a config file from which the mail script retrieve the text. So I do a constant in the config file like this:

define('_body_', 'Some text goes here\n\nSome other text goes here!');

And my mail script will now look like this:

$body = _body_;

But now the linebreaks is not "shown" in the mail. Instead the mail looks like this:

"Some text goes here\n\nSome other text goes here!"

Any ideas on how to fix this?


Solution

  • \n will be translated to a line break if it is inside double quotation marks (as in your first example) but not inside single quotation marks (as in your second example).