【问题标题】:summernote + PHP MailerSummernote + PHP 邮件程序
【发布时间】:2015-09-03 20:48:28
【问题描述】:

我尝试使用summernote

和 PHP Mailer 将内容发送到我的电子邮件。

但电子邮件似乎不是 HTML 格式,尽管我输入了:

$mail->IsHTML(true); //set email format to HTML

以下是我发送电子邮件的代码:

require '../PHPMailerAutoload.php';

$mail = new PHPMailer();

$mail->IsSMTP(); //set mailer to use SMTP
$mail->Host = "mail.xxxyy.com"; //specify SMTP mail server
$mail->Port = "2525"; //specify SMTP Port
$mail->SMTPAuth = true; //turn on SMTP authentication
$mail->Username = "xxxxx@xxxxx.com"; //Full SMTP username
$mail->Password = "xxxxx"; //SMTP password

$mail->From = "xxxxx@xxx.com";
$mail->FromName = "xxxxx";
$mail->AddAddress("xxxxxx", "Mei Yi");

$mail->WordWrap = 50; //optional, you can delete this line
$mail->IsHTML(true); //set email format to HTML

$mail->Subject = "RE:". $_POST[txtFeedbackSubject2];

$mail->Body = htmlspecialchars($_POST['content']);

if(!$mail->Send())
{
echo "Message could not be sent.

";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}

echo "Message has been sent";

邮件内容看起来是这样的:

<span style=\"font-weight: bold; font-style: italic; text-decoration: underline;\">Aadadssdasadsad.</span> 

请指教。

谢谢。

【问题讨论】:

  • 会不会是你的魔术引号启用了?

标签: php html email phpmailer summernote


【解决方案1】:

您将htmlspecialchars 应用于正文,这将阻止呈现HTML。不要那样做。

除此之外,您的邮件正文将是$_POST['content'] 中的任何内容,PHPMailer 无法控制。

【讨论】:

  • 嗨。如果我删除 htmlspecialchars,我的句子就不会变粗。如何确保我的电子邮件收到来自summernote 文本区域的粗体句子?
  • 你为什么这么说?应用 htmlspecialchars 将破坏所有 html 格式,有效地将其转换为纯文本。是否存在某种双重编码?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-01-14
  • 2017-04-19
  • 1970-01-01
  • 1970-01-01
  • 2019-07-19
  • 1970-01-01
  • 2015-08-10
相关资源
最近更新 更多