Php Mailer problem - messages marked as spam - [closed]

时光怂恿深爱的人放手 提交于 2020-01-04 06:24:21

问题


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...


回答1:


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?




回答2:


A few bullet points from a previous answer:

  • Most important: Does the sender address ("From") belong to a domain that runs on the server you send the E-Mail from? If not, make it so. Never use sender addresses like xxx@gmail.com. User reply-to if you need replies to arrive at a different address.

  • Is your server on a blacklist (e.g. check IP on spamhaus.org)? This is a possibility when you're on shared hosting when neighbours behave badly.

  • Are mails filtered by a spam filter? Open an account with a freemailer that has a spam folder and find out. Also, try sending mail to an address without any spam filtering at all.

  • Do you possibly need the fifth parameter "-f" of mail() to add a sender address? (See mail() command in the PHP manual)

  • If you have access to log files, check those, of course.

  • Do you check the "from:" address for possible bounce mails ("Returned to sender")? You can also set up a separate "errors-to" address.



回答3:


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...

This line takes care of that

$mail->AddAddress($recipient,$recipient_name);

It actually creates the TO header for the email.



来源:https://stackoverflow.com/questions/2579473/php-mailer-problem-messages-marked-as-spam

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!