开发者

\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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜