我尝试使用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>
请建议。
感谢。
答案 0 :(得分:0)
您正在将htmlspecialchars
应用于正文,这将阻止HTML呈现。不要那样做。
除此之外,您的邮件正文将是$_POST['content']
中的任何内容,PHPMailer无法控制。