Reputation: 4305
I have just started using PHPMailer and I cant get my HTML emails to send and render properly. I can get them to send fine but when I add the isHTML(true) method the email doesnt send at all. Is there anything I need to put inside the HTML email or layout differently.
Here is the html email:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>This is a test email</h1>
<p>Congratulations, {NAME}</p>
<p>You have won {PRIZE}</p>
<img src="{DOMAIN}assets/images/generated_barcodes/actual-000000013.png" alt="Barcode">
</body>
</html>
Here is the sequence of methods I use to send the email:
$this->_mail = new PHPMailer();
$this->_mail->From = FROM_EMAIL;
$this->_mail->FromName = FROM_EMAIL_NAME;
$this->_mail->addAddress($email);
$this->_mail->Subject = $subject;
$this->_mail->Body = $body;
$this->_mail->isHTML(true);
$this->_mail->send()
Just to clarify this email sends fine if I comment out the isHTML(true) method but it obviously doesn't render the HTML.
Thank you in advance!
EDIT
Seems like I just had to use the $this->_mail->msgHTML($body, DOMAIN); method to load in my HTML. But now I have a new issue. The email sends but not while in an AJAX request. I need it to send an email when I post some data with AJAX.
Upvotes: 0
Views: 236