\r\n 使用 PhpMailer 库发送电子邮件时替换不工作
我一直在尝试使用 PHP 邮件库发送电子邮件,并取得了部分成功。
我面临的唯一问题是,当收件人收到邮件时,每个新行都显示为 \r\n 。
我已经尝试过这个:
$body = str_replace("\\r\\n", '\n', $body);but it shows a '\n' instead 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?
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' instead 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它需要是:
你的第一个例子几乎是正确的,除了你在单引号而不是双引号内有 \n 。
It needs to be:
Your first example was almost right, apart from that you had \n inside single quotes instead of double quotes.
试试这个
这对我有用
Try this
It works for me