\r\n Replace not working while sending Emails using PhpMailer Library
I have been trying to send emails, using the PHP Mail Library and have been partially successful.
The only problem that I am facing is, when the Mail is received by the receiver, every new line is shown as \r\n .I have tried this:
$body = str_replace("\\r\\n", '\n', $body);but it shows a '\n' i开发者_如何学运维nstead of a new line. I have also tried this:
$body = str_replace("\\r\\n", "\\n", $body);but it shows nothing but a blank space. No new lines still :( Can someone help me on this?
It needs to be:
$body = str_replace("\r\n", "\n", $body);
Your first example was almost right, apart from that you had \n inside single quotes instead of double quotes.
Try this
Blockquote$body = stripcslashes(isset($body) ? preg_replace(' (\\r|\\r\\n|\\n)#', '
', $body) : false); $body = str_replace("
","
",$body);
It works for me
精彩评论