Php Mailer problem - messages marked as spam -

user picture user · Apr 5, 2010 · Viewed 11k times · Source

A few days ago I upgraded Php Mailer and now some email providers my messages mark as spam. This is what I see in the headers of the marked messages:

X-SpamTest-Info: {TO: header missing}

This is from my php file.

$mail->From       = $sender;
$mail->FromName   = $sender_name;
$mail->Subject    = $subject;
$mail->Body       = $body;
$mail->AddAddress($recipient,$recipient_name);
$mail->AddReplyTo($replyto,"No-Reply");

Dont know how to add "to" header and can't understand how it's possible that "to" is missing but email arrives to the correct "to" address...

Answer

Paul Tomblin picture Paul Tomblin · Apr 5, 2010

It's easy for mail to be sent without a "To:" header, because there are actually two things going on here. The "To:" header is really only there for humans to look at - the actual delivery is controlled by what is called the "envelope". When you send your message in a normal mailer, it initiates an SMTP conversion where it takes the addresses listed in the "To" header, the "CC" header, and the "BCC", strips off the BCC header, and it says to the SMTP receiver "RCPT TO: address1, address2, ..." and the SMTP receiver knows who to send it to without looking at the headers. It only looks at the headers to do spam checking, because mail that is missing To headers often indicates spam.

If there wasn't an envelope like that that was accessible to the mail transfer agents but not the end users and their mail user agents, it wouldn't be possible to use BCC.

I don't know the syntax of PHP Mailer, but does it support a "$mail->To" setting?