Reputation: 333
I have an application that sends email with following contents..
$message= "Hi, some_content \n some_content_on_new_line".
I want some_content_on_new_line on new line in email, but when the email is sent, "\n" is not interpolated to a newline character. Instead it is displayed as a backslash followed by an 'n'. How can I prevent this? This is my email config.
mail($to, $subject, $message, $headers)
Upvotes: 0
Views: 726
Reputation: 64526
If \n
is showing in the email content then most likely the problem is the use of single quotes to define the string literal.
$message= 'Hi, some_content \n some_content_on_new_line';
// this will show the \n
$message= "Hi, some_content \n some_content_on_new_line";
// this will interpolate the newline properly
Upvotes: 1