php mail() Goes to spam but when sent via SMTP Server it works fine? [closed]

天涯浪子 提交于 2019-11-28 10:12:18

问题


I am currently setting up my webserver so then i can send emails via PHP Code, the problem i have is that the emails sent via php mail() always send to my gmail spam where as when im sending emails via the SMTP Server the same VPS has on it on Gmail it dont send to spam.

Is their anyone that can help with this?

Updates:

Sending Via Ryan@Ryanteck.org.uk & Noreply@Mc-Serverlist.co.uk For PHP Mail() (Same happens with ryan@ryanteck.org.uk)

When Sent Via PHP Mail() Or Webmin Email It Sends To Spam

When Sent Via SMTP Server Via Gmail it sends ok

PHP Mail Raw Message : http://pastebin.com/TP2UfDP7 (This is the Noreply@Mc-Serverlist.co.uk)

Webmin Email System : http://pastebin.com/2VWvDd7v

Gmail SMTP : http://pastebin.com/wgewGnmk


回答1:


Your vps doesn't have rDNS configured and the HELO points to a different ip. inconsistencies in HELO and missing rDNS trigger many spamfilters.

Received: from ryanteck.org.uk ([95.154.250.75])

Host 75.250.154.95.in-addr.arpa. not found: 3(NXDOMAIN)

ryanteck.org.uk has address 95.154.250.165

Set a HELO Hostname whose A-Record points back to your VPS and configure the rDNS (PTR) to the same hostname.

Example:

  • Create a new A-Record 'vps.ryanteck.org.uk 95.154.250.75'
  • Set the HELO to 'vps.ryanteck.org.uk'
  • Set the reverse DNS (PTR) for 75.250.154.95 to vps.ryanteck.org.uk

Also your senderdomains have somewhat strange "TXT" records:

dig txt mc-serverlist.co.uk +short 
"95.154.250.165"
dig txt ryanteck.org.uk +short
"95.154.250.165"

you may want to change these into correctly formatted SPF records, eg.

v=spf1 ip4:95.154.250.165 ip4:95.154.250.75 ~all



回答2:


Try this:

mail('my@gmail.com', 'my subject', 'my text', 'From: noreply@myweb.com', '-f noreply@myweb.com');



回答3:


Set the -f noreply@myweb.com parameter, as described in PHP ref

For example, this can be used to set the envelope sender address when using sendmail with the -f sendmail option.

The user that the webserver runs as should be added as a trusted user to the sendmail configuration to prevent a 'X-Warning' header from being added to the message when the envelope sender (-f) is set using this method. For sendmail users, this file is /etc/mail/trusted-users.



来源:https://stackoverflow.com/questions/8525724/php-mail-goes-to-spam-but-when-sent-via-smtp-server-it-works-fine

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