Quick Tip: Setting an SPF record

Posted by Curtis Miller Curtis Miller

I recently noticed a lot of rejected emails coming from a production app that had just switched to send mail through Google Apps. For some reason Google felt we might be spammers, so it began rejecting our emails out-of-hand. We would continuously get the following error message:

Technical details of permanent failure:
Message rejected.  See http://mail.google.com/support/bin/answer.py?answer=69585 for more information.

That wasn't very helpful, but with a little digging it led me to find out about something called an SPF and convinced me that I should set this up. It was really easy and I suggest you do it if you're sending mail from your Ruby on Rails application through Google Apps (or some other means).

When using Google Apps, simply add a TXT record to your DNS settings with the following value:

v=spf1 mx include:aspmx.googlemail.com ~all

Note also that Google wants you to use include and specify all with a tilde(~), not a plus(+) or minus(-).

Publishing an SPF record that lacks include:aspmx.googlemail.com or specifying -all instead of ~all may result in delivery problems.

I also contacted Google to let them know of the error and if you start seeing this, be sure to let them know, too. Either that or setting the SPF record corrected our problem and we no longer get the rejected emails…


Velocity Labs

Need web application development, maintenance for your existing app, or a third party code review?

Velocity Labs can help.

Hire us!