PHPmailer sends to junk email

耗尽温柔 提交于 2019-12-04 12:08:02

Some reasons your mail can get marked spam:

  1. You're sending spam
  2. Your IP, or a block of IPs surrounding your IP has been marked as a spam source on one or more blackhole lists
  3. The content of the email is triggering spam filters.
  4. The recipient has added you to their blacklist
  5. The recipient didn't add you to their whitelist
  6. You're sending a mixed source mail ("From: xyz@example.com", but sending it from "someotherdomain.net")
  7. SPF records for your server are misconfigured/not configured at all
  8. Domain keys are misconfigured/not configured at all

etc...

PHPMailer is a tool. Consider it a hammer. The hammer may have bent the nail, but only because the wielder didn't aim right.

The only way you'll solve this problem is by examining the bounce messages (if any), and whatever showed up in the recipient's mailbox. If they receive the mail, but it goes into a spam folder, then get a copy of the mail and examine its headers. Most spam filters will put their spam score/reasoning in there.

Small hint:

add in a line like so

 $mail->AddReplyTo( 'mailer@blah.com', 'Contact BLah' );

It should decrease your SPAM rating significantly.

I was having the same problem using PHPMailer, and here's what fixed the problem for me: set the Sender (this is different and distinct from the "From") to a valid email account for the domain you are sending the email from. This causes PHPMailer to properly set the "envelope-from" information so that the email passes SPF and Sender-ID validation. Without doing this, the "envelope-from" is a OS user id and server combination which will not be verifiable.

Example Code:

$mail = new PHPMailer;

$mail->From = 'from_email@domain.com';
$mail->Sender = 'sender_email@domain.com';
...

It is not necessarily PHPMailer's fault, there are several possible reasons for your server to be blacklisted. You can check here to see if this happened

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