SPF record generator
Pick the services and servers that send mail for your domain and copy one SPF record that follows RFC 7208. It counts the DNS lookups as you go, and runs in your browser: nothing is looked up or sent.
What the parts mean
- v=spf1
- The version. It has to come first, written exactly like this, or receivers do not see the record as SPF.
- include
- Allows the servers of another domain, usually a mail service. The receiver reads the SPF record of that domain too, which costs DNS lookups.
- mx and a
- Allow the servers in the MX records of your domain (mx) or the server at its own address (a). One lookup each.
- ip4 and ip6
- Allow an address or a range, such as
ip4:203.0.113.0/24. No lookup needed, so they never count towards the limit. - ~all and -all
- What happens with mail from every other server: ~all soft fail, -all fail. Always the last part of the record.
SPF alone is not enough
SPF checks the envelope sender, the address receivers bounce mail to, not the From address your recipients see. That is why DKIM and DMARC are needed as well: DMARC ties SPF and DKIM to the From address and tells receivers what to do when both fail.
Keep it working
An SPF record breaks quietly: a mail service adds lookups to its include, a new tool publishes a second record, or someone removes a server that still sends. The SPF record check of DoubleCheck reads your record every day, counts every lookup through all includes and alerts you before your mail starts to fail.
Frequently asked questions
What is the difference between ~all and -all?
Both cover every server not in the record. With ~all (soft fail) receivers accept that mail but treat it as suspect; with -all (fail) it fails SPF. Start with ~all while you are still finding all your senders, and move to -all once the list is complete. The SPF record check warns about ~all until you do, unless you choose to accept soft fail.
Why is there a limit of 10 lookups?
Every include, a and mx makes the receiver do a DNS lookup, and an include can contain more of them. RFC 7208 caps the total at 10. Above it, receivers return an error and SPF fails for all your mail, also for the servers that are listed.
Can I have two SPF records?
No. With more than one record that starts with v=spf1 on the same name, receivers return an error and SPF fails. Put every sender in one record.
Does this generator look up my domain?
No. Everything happens in your browser. Nothing is looked up or sent anywhere, so it cannot see your current record or count the lookups inside an include.
How do I know my record keeps working?
Services change their includes, and a new tool quietly adds a second record. The SPF record check reads your record every day, counts all its lookups and alerts you when it breaks.
The standard behind this generator
SPF is defined by RFC 7208 (2014) on the Standards Track. The generator applies these requirements:
- Where the record lives
- A TXT record on the domain itself, not on a subdomain such as
_spf(section 3). A name may have only one SPF record; with more, receivers return permerror (section 4.5). - Order
v=spf1first (section 4.5). Receivers read the mechanisms from left to right and stop at the first match (section 4.6.2), soallgoes last.- Ten lookups
- include, a, mx, ptr, exists and redirect each need a DNS lookup, counted through every include; more than 10 is a permerror (section 4.6.4). ip4, ip6 and all need none.
- No ptr
- The ptr mechanism is slow and unreliable, and RFC 7208 says not to use it (section 5.5). The generator never writes it.
- Length
- One string in a TXT record holds at most 255 characters; a longer record is split into several strings that receivers join (section 3.3). Keep the whole answer under 512 bytes, so it fits in one UDP packet (section 3.4).
Not in the generator: exists, redirect and macros. They are rarely needed and easy to get wrong.
Keep your SPF record in check
Start with €5 of free credit, no credit card required. Alerts by email, SMS, Slack, Microsoft Teams or Discord.