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
PHP Pdo VS Normal MySQL_Connect
Why Can't PHP Create a Directory with 777 Permissions
How to Convert Datetime to Iso 8601 in PHP
Handling Expired Token in Laravel
How to Rename Sub-Array Keys in PHP
Running Two PHP Versions on the Same Server
How to Separate Date and Time from Datetime in MySQL
Laravel 5.5 the Page Has Expired Due to Inactivity. Please Refresh and Try Again
How to Update/Edit a JSON File Using PHP
Converting Object to JSON and JSON to Object in PHP, (Library Like Gson for Java)
How to Set Default Value for Form Field in Symfony2
Laravel Eloquent Display Query Log
Need a Good Regex to Convert Urls to Links But Leave Existing Links Alone
Removing Last Comma from a Foreach Loop
Php: Force File Download and Ie, Yet Again
Passing PHP Variable into JavaScript