summernote + PHP Mailer

694 views Asked by At

I tried using summernote

and PHP Mailer to sent the contents to my e-mail.

But the e-mail does not appear to be in HTML form eventhough I put :

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

Below is my code for sending e-mail:

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 = "[email protected]"; //Full SMTP username
$mail->Password = "xxxxx"; //SMTP password

$mail->From = "[email protected]";
$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";

The e-mail content appears to be like this:

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

Please advice.

Thanks.

1

There are 1 answers

2
Synchro On

You're applying htmlspecialchars to the body, which will prevent the HTML from being rendered. Don't do that.

Apart from that, your message body will be whatever is in $_POST['content'], over which PHPMailer has no control.