What an SPF record does
SPF (Sender Policy Framework) is a TXT record on your domain that lists the servers allowed to send email for it. When a message arrives, the receiving server looks up the record for the domain in the envelope sender and checks whether the sending IP is on the list. If it isn't, the result is a fail or soft fail, depending on the rule at the end of your record.
SPF on its own doesn't stop spoofing of the From address people see. It becomes useful when it passes alongside DMARC, which checks that the domain SPF approved matches the From domain. That's why mailbox providers now expect SPF, DKIM and DMARC together on any domain that sends in volume.
How to read an SPF record
Every record starts with v=spf1, followed by mechanisms that are checked left to right, and ends with an all rule for everything else.
- include: points to another domain's SPF record, usually your email provider's.
- ip4: and ip6: list addresses or ranges directly.
- a and mx approve whatever IPs your A or MX records point to.
- ~all, -all or ?all decide what happens to mail from servers not on the list.
A worked example
Say your team uses Google Workspace for the inbox, SendGrid for product emails and one office server on 203.0.113.5. Tick the two services, add ip4:203.0.113.5 and keep ~all. The generator returns:
v=spf1 ip4:203.0.113.5 include:_spf.google.com include:sendgrid.net ~all
The IP comes first because it needs no DNS lookup. The two includes use 2 of your 10 lookups. Publish it as a TXT record with the host @ and a TTL of an hour, and you're done.
The 10 DNS lookup limit
To check SPF, receivers may perform at most 10 DNS lookups. Every include, a, mx, ptr and exists costs one, and the lookups inside each include count too, because most provider records contain includes of their own. Go over 10 and SPF returns a permanent error, which counts as a fail for every message.
The counter above shows the lookups in your own record. If you're at 7 or more, check the published record with an SPF checker that follows includes. To get back under the limit:
- Remove tools you no longer send from. Old trials are the usual culprit.
- Move bulk sending to a subdomain such as mail.example.com, with its own SPF record.
- Replace an include with the provider's ip4/ip6 ranges only if they publish fixed ones, and review them regularly.
Common SPF mistakes
- Two SPF records. A domain can only have one TXT record that starts with v=spf1. Two or more make SPF fail. Use Import to merge them.
- Using +all. It authorises every server on the internet to send as you. Never publish it.
- Forgetting a tool. Your CRM, billing system or help desk may send as your domain. Check what each one says in its domain settings.
- Private IPs. Addresses like 10.0.0.5 or 192.168.1.20 are never seen by receivers, so listing them does nothing.
- Jumping straight to -all. Start with ~all, watch your DMARC reports, then tighten.
Choosing ~all or -all, and going live
Both protect you once DMARC is in place, because DMARC decides what happens to failing mail. ~all is the safer default while you confirm every sender is listed. Move to -all when your DMARC reports show nothing legitimate failing. ?all (neutral) says nothing about unlisted servers, so treat it as a testing option only.
DNS changes usually show up within minutes, though they can take longer if your old record had a long TTL. Send a test email to an inbox you control and check the headers for spf=pass. Then turn on DKIM signing in each sending tool and publish a DMARC record.
Related tools
Create your policy with the DMARC Generator, check your copy with the Spam Words Checker, and model a campaign with the Cold Email ROI Calculator. Want domains, warm-up and deliverability handled for you? See our cold email service.