Mailgun SPF not Aligned

I signed up for a free Mailgun account in order to send notifications from a self host Affine instance. Everything went rather smooth except for SPF which was not aligned, i.e. the IP address receiving mail servers see are not included in the SPF record.

The SPF record Mailgun asked to add was:

"v=spf1 include:mailgun.org ~all"

But Gmail kept on failing on SPF (instead of PASS it said FAIL):

Gmail SPF results


The Fix

How I got it to pass was to change the SPF record to the following:

“v=spf1 include:mailgun.org include:_spf.mailgun.org ~all”

(For EU users you have to add “spf.eu.mailgun.org” instead)


Additional Information

Doing a “dig” on _spf.mailgun.org returns two additional records:

  • spf1.mailgun.org
  • spf2.mailgun.org
Dig spf.mailgun.org


And doing a “dig” on these 2 returns all the IP addresses:

Dig spf1.mailgun.org

necrolingus

Tech enthusiast and home labber