SPF record generator
Build the SPF record for your domain. Tick the services that send email for you, add any of your own servers, and copy the finished TXT record. It counts the DNS lookups as you go, so you stay under SPF's limit of 10.
Already have an SPF record? Import it
Your SPF record
Type
TXT
Name or host
@
Value
v=spf1 ~all
Everything runs in your browser. Nothing you type is stored or sent anywhere. Once it's published, check it with the email DNS checker.
How this generator works
SPF (Sender Policy Framework) is a TXT record on your domain listing the servers allowed to send email as you. Receiving servers check it against the server that actually sent each message. The generator puts the record together from what you tick:
v=spf1starts every SPF record.mxandaallow the servers your MX and A records point to.ip4:andip6:allow single addresses or ranges.include:pulls in another service's SPF record, so when Microsoft or Google change their servers you don't have to.~all,-allor?allat the end says what to do with email from anywhere else.
It also counts DNS lookups. The SPF standard (RFC 7208) lets a receiver make at most 10 DNS lookups while checking your record, counting every include, a, mx, ptr, exists and redirect, including the ones inside the services you include. Go over 10 and SPF returns a "PermError", which counts as a fail, so email from every service on the list can start going to spam. IP addresses don't use any lookups.
Over the limit? Flattening and other fixes
If you're over 10, try these in order:
- Remove services you no longer use. Old newsletter tools and previous email hosts are the usual culprits.
- Send bulk email from a subdomain. Marketing tools can usually send from something like
news.example.co.uk, which has its own SPF record and its own 10 lookups. - Drop
mxandaif those servers don't actually send email. - Flatten as a last resort. Flattening replaces an
includewith the IP addresses it currently resolves to, so it uses no lookups. The catch is that when the provider changes its addresses your record goes out of date and their email starts failing, so it needs checking regularly or a service that does it automatically.
Our guide to fixing "too many DNS lookups" goes through each step in detail.
Common provider includes
| Service | Include | Lookups |
|---|
Tips
- Publish one SPF record only. If your domain has two TXT records starting
v=spf1, SPF fails for all your email. Merge them: paste both into "Import" above and it combines them. - Never use
+all. It allows every server on the internet to send as you, which defeats the point. - Don't use
ptr. The standard says not to: it's slow, unreliable and some receivers ignore it. - SPF alone isn't enough. Set up DKIM in each service too, then add a DMARC record with the DMARC record generator so receivers know what to do with email that fails.
- Domains that never send email should have
v=spf1 -all, which says no server may send for them. Untick everything here to get it. - Check it once it's live with the email DNS checker, which follows every include and gives the real lookup count, or see all your TXT records with the DNS lookup.
Frequently asked questions
What is an SPF record?
A TXT record in your domain's DNS that lists the servers allowed to send email for your domain. It starts v=spf1 and ends with an all rule for everything else.
Where do I add the SPF record?
Wherever your domain's DNS is managed, usually where you bought the domain or Cloudflare. Add a TXT record with the host or name @ (meaning the domain itself; some panels want it left blank) and the value from the generator. If there's already a v=spf1 record, edit that one instead of adding a second.
Should I use ~all or -all?
Either is fine once DMARC is in place, because DMARC decides what happens to failing email. ~all is the common default and safer while you're still finding every service that sends for you. -all is stricter and suits a domain whose senders you're sure of.
What is the SPF 10 lookup limit?
Receivers stop after 10 DNS lookups when checking SPF. Every include, a, mx, exists and redirect counts, including those nested inside includes. Over 10, SPF fails with a PermError.
Can I have two SPF records?
No. Two v=spf1 records on the same name make SPF fail. Combine everything into one record.
How long until a new SPF record works?
Usually minutes, but up to the old record's TTL (often an hour, sometimes a day) before every receiver sees the change.
Does it save or send what I type?
No. The record is built in your browser and nothing is stored or sent anywhere. It doesn't look anything up either, so to check a published record use the email DNS checker.