Reputation: 1221
I have problems with sending html based message with php mailer. Some answers here in stackoverflow says to include $mail->isHTML(true) which i do but no result.. here is the code
require '...';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = '...';
$mail->SMTPAuth = true;
$mail->Username = '...';
$mail->Password = '...';
$mail->setFrom("....");
$mail->addAddress("...");
$mail->Subject = "...";
$mail->Body = "<li>abcd</li>";
$mail->isHTML(true);
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
Does anyone know what's wrong?
Thanks!
Upvotes: 1
Views: 1489
Reputation: 74217
<li>abcd</li>
isn't enough and <ul></ul>
tags should also be included. You need to use <!DOCTYPE html><head></head><body>...</body></html>
as proper and full HTML markup and concatenating $mail->Body
.
$mail->Body = "<!DOCTYPE html>"; // the first one does not contain the dot
$mail->Body .= "<head></head>";
$mail->Body .= "<title></title>";
$mail->Body .= "<body>";
$mail->Body .= "<ul>";
$mail->Body .= "<li>abcd</li>";
$mail->Body .= "</ul>";
$mail->Body .= "</body>";
$mail->Body .= "</html>";
You can also substitute <ul></ul>
for <ol></ol>
depending on the type you want to use.
Upvotes: 3