Search code examples
phphtmlemailspamassassin

How to prevent the email from being considered HTML, when I've already set the headers as "Content-type: text/plain"


I'm trying to figure out why my emails are considered spam by hotmail, so I'm using an online tool called mail-tester.com.

According to it, I have an 8.4 out of 10, but one of the problems is that SpamAssasin detected that "Message only has text/html MIME parts", it adds that "You should also include a text version of your message (text/plain)" and it points a link to the spamAssasin rule "MIME_HTML_ONLY"

Myq uestion is: I'm sending the emails using phpMailer. My email is not blacklisted and this just happens with hotmail.

I'm setting the headers as text/plain.

I'm putting the email content into the strip_tags() function.

Why it says that I'm sending HTML?

This is what I'm using (the whole script is quite long, but this is the pertinent part that sends the email. I do receive the email without issues in other email clients, like gmail.

require $_SERVER['DOCUMENT_ROOT'].'/phpMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'mail.mysite.online';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Port = 25;
$mail->CharSet = 'UTF-8';
$headers .= 'Content-type: text/plain'; 

$mensajeLimpio = strip_tags($resultado['mailMensaje']);
$mail->addAddress($pedidoEmail);
$mail->Subject = $resultado['mailAsunto'];
$mail->Body    = 'Estimado/a '.$nombreUsuario.',<br>'.$mensajeLimpio;

Solution

  • Add $mail->IsHTML(false); to your options