Combining SPF records for Gmail and Mailgun services

I’m trying to set up email authentication for my domain and need to combine SPF records from two different services.

I have these separate SPF configurations:

For Gmail: v=spf1 a mx include:_spf.google.com ?all

For Mailgun: v=spf1 include:mailgun.org ~all

I merged them into this single record: v=spf1 a mx include:_spf.google.com include:mailgun.org ~all

I’m wondering if the “a mx” mechanisms and the “~all” qualifier at the end are correct in my combined version? Should I be concerned about any conflicts between these parts when both services are included?

The merged record looks right, but here’s something about mechanism order. SPF checks mechanisms left to right until it hits a match. Putting “a mx” before the includes means if someone sends from your domain’s A or MX record IPs, it’ll pass without even touching Google or Mailgun’s records. That’s usually what you want for speed. Pro tip I learned the hard way - always test your SPF record with multiple online validators before going live. Different validators catch different edge cases. And don’t set your DNS TTL too high. I once had a typo that took 24 hours to fix because of a crazy high TTL setting.

Your SPF record looks good. The “a mx” parts are right - they let your domain’s A record and MX servers send mail, which is what you want. The “~all” at the end is actually better than the “?all” from your Gmail setup. It blocks suspicious mail but won’t kill legitimate emails. I’d test this thoroughly before switching over though. I’ve seen email get weird during transitions from separate records to combined ones. Also double-check that your registrar actually updates the TXT record - some cache things badly and you’ll get temporary auth failures.

looks good! the ~all at the end is fine. just be aware of the 10 dns lookup limit, but should be fine for gmail and mailgun. might wanna check it with an spf checker to be safe!

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.