Home > DNS, PHP > Stop mails sent from PHP being marked as spam by editing SPF records!

Stop mails sent from PHP being marked as spam by editing SPF records!

So I just moved servers and my inbound mail traffic was going down each day.. I took a look at the mail headers and got this:

Return-Path:
Received-SPF: neutral (google.com: 66.x.x.x is neither permitted nor denied by best guess record for domain of support@thaifriendly.com) client-ip=66.x.x.x;

I managed to change this from a neutral to a pass by adding a return path to my mail command in PHP:

mail($toemail,$subject,$message,$headers," -f support@mydomain.com");

.. and by logging into namecheap and adding a TXT record to my domain (Login -> select domain -> All host records) for host name add @ for IP address/URL add “v=spf1 a:my.mailserver.ip.address ~all” and selecting “TXT Record”. After saving changes and sending a test mail google now happily reports:

Return-Path:
Received-SPF: pass (google.com: domain of support@mydomain.com designates my.mailserver.ip.address as permitted sender) client-ip=my.mailserver.ip.address;

It took me a few searches to get all this information together, particularily editing host records in namecheap too, I hope it helps someone!

Categories: DNS, PHP Tags: ,
  1. kei
    April 29, 2010 at 4:34 am

    Thanks lampbear!

    Your solutions is the EXACT ONE I’ve been searching for!!!

    I installed DKIM and SPF in my Postfix, Cent OS 5.3 system without any problems and of course, edited TXT records flawlessly, then I had been stuck with the PHP mailer SPF problems.

    ” -f support@mydomain.com” That really relieved me of the unreached email mess.

    • April 29, 2010 at 5:45 am

      i struggled quite a bit gettin dkim working wit sendmail.. wondering if postfix is a better choice… my emails are getting delivered to the big three ok but still says apache@localhost in there and my hostname not my domain.. i think i can fix that with masquerading but its wayyyy difficult >.<

  1. No trackbacks yet.

Leave a comment