SPF Records Explained: Syntax, Examples and Common Errors
Learn how SPF TXT records authorize email senders, read mechanisms and qualifiers, find duplicate policies, and distinguish a DNS lookup from SPF validation.
An SPF record is a DNS TXT policy that authorizes servers to send mail using a particular domain in the SMTP conversation. A receiving system compares the connecting sender’s IP address with that policy. Publishing the text is only the first step: a policy can exist and still fail for a real message because the wrong domain was checked, a sender is missing or evaluation encounters an error.
This guide explains the record’s structure, how to find it, and the mistakes worth investigating. It does not prescribe one record for every organization. Your correct policy depends on all the systems that actually send mail using the relevant domain.
SPF, MX, DKIM and DMARC answer different questions
MX records describe incoming mail routing. SPF describes authorization for an outbound sending identity. Changing your mailbox provider’s MX records does not automatically authorize every system that sends email on your behalf.
SPF commonly checks the domain in the SMTP MAIL FROM, which is associated with the envelope sender or return path. It can also check the HELO/EHLO identity. These are not necessarily the same as the address displayed in the message’s From header.
DKIM adds a signature-based authentication method. DMARC connects authentication with alignment to the visible From domain and a domain owner’s policy. An SPF pass for an unrelated envelope domain does not, by itself, establish DMARC alignment.
For example, an invoicing platform might send with its own bounce domain while showing your company address in From. Determine which identity the platform uses before deciding which domain’s SPF record needs attention. The MX checking guide covers incoming routing separately.
What an SPF record looks like
The following policy is illustrative, using a documentation-only address and example service name:
v=spf1 ip4:192.0.2.10 include:mail-service.example -all
Read it from left to right:
v=spf1identifies the SPF version.ip4:192.0.2.10describes an authorized IPv4 address.include:mail-service.exampleasks evaluation to consider another domain’s SPF policy under SPF’s include rules.-allproduces a fail result for a sender that reaches this final mechanism without matching earlier authorization.
Do not publish this sample. The example address does not identify your real infrastructure, and the example service name does not stand for your email vendor. Obtain the required values from each actual sender’s current instructions.
The protocol is specified in RFC 7208, including identity selection, evaluation and result handling. SPF policies are published as TXT; the historical dedicated SPF DNS type is not the type to select in DNSBatch.
Common mechanisms and qualifiers
Mechanisms describe conditions evaluated against a sender. Qualifiers describe the result when a mechanism matches.
| Element | What to investigate |
|---|---|
ip4 and ip6 |
Authorized addresses or network ranges; confirm they belong to intended senders |
include |
Another policy dependency; use the domain your sender actually documents |
a |
Address records used by the policy; website addresses may not be the intended mail senders |
mx |
Mail-exchange-related address checks; incoming mail infrastructure is not automatically an appropriate outbound authorization |
all |
A mechanism that always matches when evaluation reaches it; normally used at the end |
An omitted qualifier defaults to pass for a matching mechanism. The commonly discussed final forms have different meanings:
-all: fail for otherwise unmatched senders.~all: softfail, not a promise of inbox or spam-folder placement.?all: neutral; the policy makes no positive or negative authorization assertion for those senders.+all: authorizes every otherwise unmatched sender and usually defeats the intended restriction.
The receiver still applies its own handling policy. Do not switch from ~all to -all as a cosmetic tightening exercise before you have inventoried and tested legitimate senders. Cloudflare’s SPF introduction provides additional background on the policy’s role in email authentication.
How to find the published SPF policy
- Identify the domain used by the sender’s envelope identity or the exact domain your provider tells you to configure.
- Open the Bulk SPF Checker and enter that domain, or paste several domains for a portfolio review.
- Run the inspection and review the published policy, syntax findings and literal include or redirect dependencies.
- For raw discovery without SPF analysis, use TXT-only DNS lookup and find the separate TXT record beginning with
v=spf1. - Preserve the complete value and resolver information before changing anything.
A terminal alternative is:
nslookup -type=TXT example.com 1.1.1.1
The general Bulk DNS Checker’s TXT view displays the resolver’s presentation of the record; it does not perform SPF policy analysis. The dedicated Bulk SPF Checker inspects syntax, follows supported literal include/redirect dependencies and reports potential lookup-limit paths. Neither tool evaluates a real sender IP against the policy. Treat record discovery, static policy findings and message authentication as separate results.
If the policy is missing from the expected name, work through the TXT lookup guide. A policy at the parent domain is not automatically inherited by every subdomain; check the identity the message actually uses.
Can you have two SPF records for the same domain?
Several unrelated TXT records at a name can be normal. Several independent TXT records selected as SPF policies at the same name are a different issue and can cause a permanent evaluation error.
Imagine a domain with one SPF policy for its mailbox provider and another for its newsletter platform. The receiver does not simply choose whichever policy authorizes the sender. The intended senders must be represented in a single valid policy for that checked name, following each provider’s supported setup.
Do not merge records by concatenating complete v=spf1 strings. Inventory the senders represented by both records, confirm their current provider instructions, and prepare one intended policy for that exact DNS name. Review syntax and dependencies with the bulk SPF record validator before publication, then test legitimate sending paths afterward. Policies at two different names, such as a root domain and a sending subdomain, are not automatically duplicates.
Google’s SPF setup workflow starts with identifying senders, including automated services and web applications. That inventory is more reliable than copying a generic record from an unrelated domain.
Understand the SPF DNS lookup limit
SPF limits DNS-triggering terms during evaluation. The familiar limit is not “ten TXT records” or “ten domains written in the policy.” Includes can introduce nested dependencies, and different mechanisms have different lookup behavior.
An apparently short policy can therefore run into a lookup-limit error. Address mechanisms such as ip4 and ip6 do not create the same policy DNS dependencies as an include, but manually replacing a provider’s includes with today’s observed addresses can become stale as the provider changes infrastructure.
Use the Bulk SPF Checker to inspect literal dependencies and potential over-limit paths. Its static analysis differs from evaluating a real message with a sender IP. Follow the SPF too many DNS lookups checklist to review nested includes and plan corrections. Cloudflare also describes the issue in its SPF lookup-limit guidance.
A record can exist while email still fails
There are several different questions to answer:
- Is the TXT policy published at the correct name? A DNS lookup can help here.
- Is that policy valid and within evaluation limits? This needs policy-aware validation.
- Does the real sending IP match the policy for the message’s checked identity? This needs message and sender context.
- Does the authenticated identity align for DMARC? This is an additional assessment.
- Will the message be delivered to the inbox? Reputation, content and receiver rules also matter.
For a failed message, inspect the recipient system’s authentication results and your mail provider’s delivery logs. Distinguish fail, softfail, temperror and permerror; they call for different investigations. Forwarding can also change the connecting sender and affect SPF. Google’s SPF troubleshooting guide discusses these operational cases.
A safe SPF review checklist
- Record the currently published policy before editing it.
- Identify mailbox providers, marketing tools, application mail and transactional services that use the checked domain.
- Confirm each service’s actual return-path configuration and documented SPF requirements.
- Keep one valid selected SPF policy at the relevant name.
- Validate dependencies and limits with a policy-aware tool.
- Send controlled test messages through each legitimate service and inspect recipient-side results.
- Remove obsolete authorizations after confirming the service is no longer sending for you.
After a change, compare DNS answers with their resolver and lookup time. Cached older policies can temporarily remain visible; the propagation guide explains why repeatedly saving the same record does not force every resolver to refresh.
For a portfolio review, use the Bulk SPF Checker to inspect policies, literal include/redirect dependencies and potential lookup-limit risks across multiple domains. It provides static configuration findings rather than a sender-specific SPF result.
Use the Bulk DMARC Checker to inspect direct and inherited message policies, alignment settings and reporting authorization alongside SPF.
When you need to edit a policy, use the SPF Record Generator to preserve its ordered terms, compare your draft with the original and copy one TXT value. Confirm every legitimate sender before publishing, then inspect the result with the Bulk SPF Checker.