PHPMailer IsHTML(true) not working
Why would you not expect it to use HTML if you call IsHTML(true)
? That's how you tell PHPMailer to treat your message body as HTML! If you don't want HTML as the content type, call IsHTML(false)
, or just don't call it at all since plain text is the default.
If you want both HTML and plain text, call msgHTML($html)
instead and it will also handle the HTML->text conversion for you.
As Chris said, call IsHTML
before setting Body
.
And as Dagon said, if you put HTML in $message
, it will send HTML...
Sarjit Delivala
IT Professional working with multiple technologies.
Updated on July 06, 2022Comments
-
Sarjit Delivala almost 2 years
I am trying to send emails from PHPMailer. Everything is working but the problem is it is sending emails along with HTML tags even after writing
$mail->IsHTML(true);
. Below is my code for sending emails.$mail = new PHPMailer(); $mail->IsSMTP(); $mail->SMTPDebug = 1; $mail->SMTPAuth = true; $mail->SMTPSecure = EMAIL_COMPOSE_SECURE; $mail->Host = EMAIL_COMPOSE_SMTP_HOST; $mail->Port = EMAIL_COMPOSE_PORT; $mail->Username = EMAIL_COMPOSE_OUTGOING_USERNAME; $mail->Password = EMAIL_COMPOSE_OUTGOING_PASSWORD; $mail->SetFrom(EMAIL_COMPOSE_INCOMING_USERNAME); $mail->Subject =$subject; $mail->Body = $message; $mail->IsHTML(true); $mail->AddAddress($email_to); if(!$mail->Send()){ echo "Mailer Error: " . $mail->ErrorInfo; } else{ echo "Message has been sent"; }
And one more thing I will mention, in my application text editor for writing the emails is ckeditor. Will that cause any problem? Please help.