PHPMailer忽略\r\\\<br/> [英] PHPMailer Ignoring \r\n

查看:168
本文介绍了PHPMailer忽略\r\\\<br/>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前收到的电子邮件是由PHPMailer使用纯文本/电子邮件发送的。我现在通过获取行并保存到一个变量$消息从数据库返回电子邮件。数据库中的消息被格式化为:

I am currently having an issue with emails received that were sent from PHPMailer using plain/text emails. I am currently returning the email message from a database by fetching the row and saving into a variable $message. The message while in the database is formatted as such:

This is some email information. \r\n This is some more email information.

收到的电子邮件是用\ r \\\
显示消息,而不是返回一个新行。

The email received is showing the message with the \r\n rather than returning a new line.

我的PHPMailer代码如下所示:

My PHPMailer Code looks similar to the following:

$subject = $row['subject'];
$message = $row['message'];

// PHP Mailer
$mail = new PHPMailer();
$mail->From = "noreply@mywebsite.org";
$mail->FromName = "MyWebsite.org";
$mail->AddAddress('recipient@email.com');
$mail->ContentType = 'text/plain';
$mail->IsHTML(false);
$mail->Subject = $subject;
$mail->Body = $message;
$mail->AltBody = $message;
if(!$email->Send()){
    echo "Mailer Error: " . $mail->ErrorInfo;
} 

我的问题:如何获得\ r \ n使用PHPMailer正确格式化?这是一个PHPMailer的设置,或者我在我的代码中做错了什么?

My question: How can I get \r\n to format properly using PHPMailer? Is this a PHPMailer setting or am I doing something wrong within my code?

推荐答案

看起来你已经保存 \r\\\
作为文本到您的数据库 - PHP不会解析。您实际上需要在数据库中的消息中保存一个新行

It looks like you've saved \r\n into your database as text - PHP will not parse that. You need actually save a new line into your 'message' in the database

这篇关于PHPMailer忽略\r\\\<br/>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆