SPF record: setup, the 10-lookup limit, and fixes
Want this checked on your own domain?
Join the waitlistUpdated
Message for whoever manages your DNS
Hi, could you review the SPF record for our domain? It’s the TXT record at the root of the domain that starts with “v=spf1”.
We need exactly one SPF record. It should list every service that sends email for us, end with “~all” or “-all”, and need no more than 10 DNS lookups.
These are the services that send email as our domain: list them here.
Thank you.
Want this checked on your own domain? Join the waitlist.
Check yours
The SPF checker (join the waitlist for access) reads your record, expands every include, and counts DNS lookups against the limit of 10. The full report checks SPF together with DKIM, DMARC, and your mail servers.
Fix it
An SPF record is a TXT record at the root of your domain. You edit it at your DNS host, the company your domain’s nameservers point to (see nameservers if you’re not sure who that is).
Build the record
- List every service that sends email using your domain. Include your mailbox provider, plus newsletters, store and billing notifications, your help desk, your CRM, and website contact forms.
- Find each service’s SPF value in its own setup instructions. It’s usually an
include:term:- Google Workspace:
include:_spf.google.com - Microsoft 365:
include:spf.protection.outlook.com
Your own servers can be listed by address withip4:orip6:. - Google Workspace:
- Skip services that don’t need a place in your root record. SPF checks the domain in the message’s bounce address (the “Return-Path”), not the address people see in the From line (technical reference). Some services use their own domain or a subdomain of yours for that address, so your root record never comes into play for their mail. To see which applies, open a message the service sent and look at the Return-Path header. If its domain isn’t your root domain, that service needs nothing in this record. Check the service’s own instructions too.
- Write everything on one line. Start with
v=spf1and end with one closing rule:v=spf1 include:_spf.google.com include:_spf.example.net ~all - Choose the closing rule. Both of these pass our check:
~all(“softfail”) marks unlisted servers as probably unauthorized. It’s the safer start, and it’s what Google recommends.-all(“fail”) says unlisted servers are not authorized. Microsoft recommends it for Microsoft 365 domains. RFC 9989 §7.1 adds a caution: some receivers act on an SPF fail early, before DMARC runs. They can reject a message that DKIM would have rescued, and those rejections never appear in your DMARC reports.
If you publish DMARC at quarantine or reject, DMARC does the enforcing, and~allavoids that early rejection. - Publish it as a TXT record at the root of the domain.
- In the host (or name) field, enter
@, or leave it blank, depending on the DNS host. Namecheap, for example, uses@for the root. - Replace any existing record that starts with
v=spf1. Don’t add a second one. - TXT records that don’t start with
v=spf1, such as site-verification codes, aren’t SPF records. Leave them alone.
- In the host (or name) field, enter
- Check the result with the SPF checker.
Long records. A single string inside a TXT record holds at most 255 characters (RFC 1035 §3.3). For a longer record, split it into several quoted strings in the same record. Receivers join the strings with nothing in between (RFC 7208 §3.3), so keep the space between terms inside one of the strings:
"v=spf1 include:_spf.google.com include:spf.protection.outlook.com " "include:_spf.example.net ~all"
How you enter this depends on the DNS host:
- Amazon Route 53 requires each string in double quotes, with all strings on the same line.
- Cloudflare adds the double quotes itself if you save a value without them.
How long changes take. Mail services see the new record once their cached copy expires. For an edited record, that takes at most the old record’s TTL, the caching time set on the record (RFC 1035 §3.2.1). A record that didn’t exist before can stay hidden for the zone’s negative-caching time wherever someone recently looked it up and found nothing (RFC 2308 §5). Google says SPF can take up to 48 hours to start working.
When you remove a sender, keep it in the record until mail it already sent has been delivered and checked (RFC 7208 §2.1).
No SPF record
What it means: The domain receives email (it has MX records), but no TXT record at its root starts with v=spf1. To a mail service, the domain makes no statement about who may send for it (the result is “none”, RFC 7208 §4.5).
Why it matters: Gmail and Yahoo require SPF or DKIM from every sender, and both from bulk senders. Without SPF, DMARC can pass only through DKIM.
Fix: Build the record with the steps above.
- If the report recognizes your mailbox provider, it shows a starting record with that provider’s include. Add the include for every other service on your list before you publish it.
- If the domain sends no email at all, publish
v=spf1 -allinstead, with the other records in spoofing protection.
Confirm: The SPF checker shows one record and the services it authorizes.
The SPF record is pasted incorrectly
What it means: A TXT record contains an SPF rule, but its value doesn’t begin with v=spf1. Mail services ignore any TXT record that doesn’t begin with exactly v=spf1 (RFC 7208 §4.5), so the domain effectively has no SPF record.
Common causes:
- a label pasted in front, such as
TXT v=spf1 …orspf v=spf1 …; - a space before
v=spf1; - quotation marks that became part of the value.
Fix: Edit the TXT record so its value begins with v=spf1 and has no stray characters at either end, including quotation marks. Some DNS hosts expect you to type quotes around a TXT value and others add them for you. Either way, the published value must not begin or end with a quote mark.
Confirm: The checker shows the record starting with v=spf1.
More than one SPF record
What it means: The root of the domain has two or more TXT records that start with v=spf1. A domain must not have more than one (RFC 7208 §3.2). When it does, every SPF check of the domain ends in “permerror”, a permanent error (§4.5), so SPF never passes for any message. It can happen when several services’ setup instructions each say to “add an SPF record”.
Fix: Merge the records into one, then delete the others.
- Write
v=spf1once. - Copy every term from every record except
v=spf1and the closingallrule, and drop duplicates. - End with a single closing rule (
~allor-all).
For example, these two records:
v=spf1 include:_spf.google.com ~all
v=spf1 include:_spf.example.net -all
become one:
v=spf1 include:_spf.google.com include:_spf.example.net ~all
Two more things to watch:
- A record can contain only one
redirect=, and aredirect=is ignored in any record that has anallrule (RFC 7208 §5.1, §6). If one of the records usesredirect=domain, useinclude:domainin the merged record instead. - Merging adds the lookups of both records together. Check the result against the limit of 10 before you publish.
Our report suggests the combined record when the records can be merged term by term, and tells you how many lookups it needs. When a record uses redirect= or another modifier, it asks you to combine them by hand instead, because the right result depends on what each provider needs.
At Amazon Route 53, all TXT values for a name are in one record set, one value per line. Delete the extra SPF line there.
Confirm: The checker shows exactly one SPF record.
The SPF record has errors
What it means: Part of the record isn’t valid SPF. A mail service checks the syntax of the whole record before it uses any of it, and one invalid term anywhere makes the result “permerror” for every message (RFC 7208 §4.6).
| Problem | Typical cause | Fix |
|---|---|---|
| Not an SPF mechanism | A typo (inlcude:), or a space after a colon (include: _spf.example.net becomes two broken terms) | Correct the spelling; remove the space |
| Requires a domain | include: or exists: with nothing after it | Add the domain, or remove the term |
| Not a valid domain or macro | A URL (include:https://…), or a stray % sign (§7.3) | Use the bare domain name |
| Requires an address / address not valid | ip4: with no address, a partial address (ip4:192.0.2), or an IPv6 address after ip4: | Write a full address or a range: ip4:192.0.2.0/24, ip6:2001:db8::/32 |
all takes no value | all: followed by something | Write just all, with its qualifier |
| Modifiers can’t have a qualifier | -redirect=… or ~exp=… | Remove the leading symbol |
| May appear only once | Two redirect= or two exp= terms (§6) | Keep one |
| Requires a value | redirect= or exp= with nothing after it | Add the domain, or remove the term |
Fix: Correct or remove each invalid part. If you don’t know what a part was for, ask the person or service that added it before you delete it.
Confirm: The checker parses the record without errors.
SPF needs too many lookups
What it means: Checking your record takes more than 10 DNS lookups.
- Each
include:,a,mx,ptr,exists:, andredirect=costs one lookup. - So does every one of those inside the records your includes point to, all counted together (RFC 7208 §4.1, §4.6.4).
ip4:,ip6:, andallcost nothing.
Past 10, the result is “permerror”.
A mail service reads the record from left to right and stops at the first term that matches (§4.6.2). A message from a server that matches early can still pass. Mail from services listed after the limit is reached fails with a permanent error, and so does forged mail, which matches nothing. So the problem can look intermittent: some services pass and others don’t. Each provider’s include can contain further includes, so the total grows quietly as services are added.
Fix, in this order:
- Remove includes for services you no longer use.
- Remove includes that don’t belong at the root. If a service’s Return-Path is on its own domain or on a subdomain of yours (step 3 of Build the record), its include in the root record is never used for its mail. Confirm with the service’s current instructions before removing it.
- List your own servers by address. Replace
aandmxterms withip4:andip6:ranges when the addresses rarely change. RFC 7208 §10.1.1 calls a record that lists addresses directly the “best record”. - Move some senders to a subdomain. For example, newsletters can send from
news.example.com, which gets its own SPF record and its own limit of 10. Microsoft recommends subdomains for bulk email services. Mail from a subdomain still passes DMARC’s default (relaxed) alignment with your main domain (RFC 9989 §3.2.10.1). - Flatten only if something keeps the copy current. “Flattening” replaces an include with the IP ranges it currently resolves to. The provider’s ranges change: Google says its mail servers’ “addresses change often”. When they do, a flattened copy goes stale, and that provider’s mail starts failing SPF without any warning. Flattened records also get long, past the size RFC 7208 §3.4 recommends.
Confirm: The checker shows 10 lookups or fewer.
SPF is close to its lookup limit
What it means: The record uses 8, 9, or 10 of its 10 allowed lookups. Ten is still within the limit; the eleventh breaks SPF, as described in SPF needs too many lookups. A new service’s include can cost several lookups at once if it contains includes of its own.
Fix: Before you add another service, remove includes you no longer need, using the steps in the previous section. To see what a new include would cost, check it with the SPF checker, which expands includes.
Confirm: The checker shows 7 lookups or fewer.
SPF refers to names that don’t exist
What it means: More than two of the record’s lookups return nothing, either because the name doesn’t exist or because it has no records of the type asked for. RFC 7208 §4.6.4 calls these “void lookups”: mail services should allow at most two, and exceeding that limit produces “permerror”.
Typical causes:
- an include for a service that has since changed its include name;
- an
a:ormx:term for a server that was retired.
Fix: Remove the terms that point to names that no longer exist. For a service you still use, replace its include with the one in its current instructions.
Confirm: The checker reports two void lookups or fewer.
SPF depends on a broken record
What it means: Something the record refers to can’t be used:
- an
include:orredirect=points to a domain that has no SPF record, more than one SPF record, or an SPF record with errors (RFC 7208 §5.2, §6.1); - an
mxterm points to a domain with more than 10 mail servers (§4.6.4).
Each of these turns into “permerror” once evaluation reaches that term.
Fix:
- A service you no longer use: remove its include.
- A service you still use: check its current setup instructions. Providers sometimes rename their include, and the old name stops working. If the service’s own record is broken, contact the service. Until it’s fixed, mail from that service can’t pass SPF through your record.
- An
mxterm: replace it withip4:andip6:ranges for the servers that actually send.
Confirm: The checker shows every include resolving to a valid record.
SPF includes loop back on themselves
What it means: An include (or redirect) leads, directly or through other records, back to a record already in the chain. A common example is a domain that includes itself: include:example.com in the record of example.com. Each pass around the loop costs more lookups until the limit of 10 is exceeded, and the result is “permerror” (RFC 7208 §4.6.4).
Fix: Remove the include that points back to an earlier record.
Confirm: The checker shows the include tree without a loop.
SPF allows anyone to send as you
What it means: The record ends in +all, or in a bare all, because a term without a symbol in front is treated as + (RFC 7208 §4.6.2). This also applies when a redirect= target ends that way. Every server on the internet passes SPF for your domain.
DMARC accepts an SPF pass whose domain matches the From address. Anyone can put your domain in a message’s bounce address, so with +all their mail can pass DMARC too.
Fix: Make sure the record lists every service that sends for you, then change the ending to ~all, or to -all once you’re certain the list is complete.
Confirm: The checker shows the record ending in ~all or -all.
SPF doesn’t say what to do with other senders
What it means: The record ends in ?all, which gives unlisted servers a “neutral” result. Mail services must treat neutral exactly like having no SPF record at all (RFC 7208 §8.2), so the record authorizes your senders but says nothing against forgers.
Fix: Once the record lists every service that sends for you, change the ending to ~all.
Confirm: The checker shows the new ending.
SPF has no closing rule
What it means: The record has no all rule and no redirect=. A record that ends without one behaves as if it ended in ?all (RFC 7208 §4.7): servers you didn’t list get a neutral result instead of a softfail or fail.
Fix: Once the record lists every service that sends for you, add ~all at the end.
Confirm: The checker shows the record ending in ~all or -all.
SPF uses the outdated “ptr” rule
What it means: The record contains the ptr mechanism, which asks mail services to look up the name behind the sending server’s IP address. RFC 7208 §5.5 says it should not be published: it is slow, less reliable when DNS has errors, and puts a large load on the DNS servers that answer those reverse lookups.
Fix: Replace ptr with the ip4: and ip6: ranges of your own servers, or with the include your provider documents.
Confirm: The checker no longer reports ptr.
Part of the SPF record is ignored
What it means: Mechanisms come after the closing all rule. Evaluation never gets past all, so mail services ignore the mechanisms after it (RFC 7208 §5.1). If those mechanisms authorize a service, that service isn’t authorized.
Fix: Move those mechanisms in front of the all rule, or remove them if they aren’t needed. all should always be the last mechanism.
Confirm: The checker no longer reports mechanisms after all.
Part of SPF could not be checked
What it means: Lookups for one or more domains your record depends on didn’t complete during the check. Mail services that hit the same problem return “temperror”, a temporary error (RFC 7208 §5), and may accept the message or ask the sender to retry later (§8.6).
What to do: Run the check again later. If the same domain keeps failing, its DNS servers may not be answering. Check that service’s current instructions, or ask the service.
SPF could not be read
What it means: The lookup for your domain’s TXT records didn’t complete during the check. Mail services in the same position return “temperror” (RFC 7208 §4.4).
What to do: Run the check again later. If it keeps failing, ask your DNS host whether its nameservers are answering for your domain.
Technical reference
What SPF checks
SPF authorizes the domain in two places (RFC 7208 §2.3, §2.4):
- The MAIL FROM address, given when the message is handed over. The receiving server records it as the Return-Path header at final delivery (RFC 5321 §4.4). When a message has an empty MAIL FROM, as bounces often do, SPF checks
postmaster@the HELO name instead (§2.4, §10.1.3). - The HELO name of the sending server.
SPF doesn’t check the From address that people see. DMARC uses only the MAIL FROM result, and counts it only when that domain aligns with the From domain (RFC 9989 §3.2.4, §4.4.2). See DMARC.
Forwarding and mailing lists resend a message from their own servers. If they keep the original MAIL FROM, SPF fails (RFC 7208 §10.3). DKIM signatures generally survive forwarding (RFC 9989 §7.4), but not a mailing list that changes the message, for example by tagging the subject or adding a footer (RFC 7960 §3.2.3). That’s why DKIM matters even when SPF is correct.
SPF is published only as a TXT record. The separate SPF record type from SPF’s experimental phase has been discontinued (RFC 7208 §3.1).
Syntax
A record is v=spf1 followed by terms separated by spaces (RFC 7208 §4.5, §4.6.1). Mechanism and modifier names are case-insensitive.
| Term | Matches when the sending IP… | DNS lookups (§4.6.4) |
|---|---|---|
ip4:192.0.2.0/24, ip6:2001:db8::/32 | is in the network (no prefix means a single address) | 0 |
a, a:host.example.com, a/24 | is an address of the domain (A for IPv4 senders, AAAA for IPv6) | 1 |
mx, mx:example.com | is an address of one of the domain’s mail servers | 1, plus at most 10 address lookups |
include:example.net | passes the other domain’s SPF check | 1, plus that record’s own lookups |
exists:%{i}._spf.example.com | the constructed name has an A record | 1 |
ptr | has a reverse name in the domain. Don’t use it (§5.5) | 1, plus up to 10 address lookups |
all | always matches. Put it last | 0 |
Qualifiers go in front of a mechanism and set the result when it matches (§4.6.2): + pass (the default), - fail, ~ softfail, ? neutral.
Modifiers (§6):
redirect=domainapplies when nothing in the record matched.exp=domainpoints to a TXT record whose text explains a fail.
redirect= and exp= may each appear at most once. Modifiers that a mail service doesn’t recognize are ignored, wherever and however often they appear.
Results
| Result | Meaning (RFC 7208 §2.6) | Handling (§8) |
|---|---|---|
| pass | The server is authorized | Counts toward DMARC if the domain aligns |
| fail | Explicitly not authorized | Local policy; may be rejected with 550 5.7.1 |
| softfail | Probably not authorized | Receivers should not reject on this alone |
| neutral | No assertion | Must be treated exactly like none |
| none | No SPF record, or no valid domain to check | No information |
| temperror | A temporary DNS error | Accept, or ask the sender to retry later |
| permerror | The record can’t be interpreted | Needs a fix by whoever manages the DNS |
Evaluation
Mechanisms are tried from left to right, and the first match decides (§4.6.2). If nothing matches and there is no redirect=, the result is neutral (§4.7). Mechanisms after all are ignored, and so is a redirect= anywhere in a record that contains all (§5.1, §6.1). An exp= applies wherever it appears (§6, §6.2).
include: and redirect= behave differently:
include:borrows only a pass. A fail, softfail, or neutral from the included record doesn’t end the evaluation; your record moves on to its next term. An included domain with no SPF record, or with a broken one, makes the whole check “permerror” (§5.2).redirect=hands the entire decision to the other record, including its closing rule. If that domain has no SPF record, the result is “permerror” (§6.1).
Use include: for services run by other organizations. Use redirect= when several domains you control should share one record (§5.2, §6.1).
Limits
- 10 lookups: the terms that cause DNS lookups (
include,a,mx,ptr,exists,redirect) are limited to 10 per check, counted across every nested record. Exceeding the limit gives “permerror”.exp=is not counted (§4.1, §4.6.4). - Mail servers: an
mxterm may cause at most 10 address lookups, and more gives “permerror”. Forptr, names beyond the first 10 are ignored (§4.6.4). - Void lookups: lookups that return no answer or a name that doesn’t exist should be limited to two, and more gives “permerror” (§4.6.4, §11.1).
- Time: mail services should allow at least 20 seconds per check. Running out gives “temperror” (§4.6.4).
- Size: each string in a TXT record holds up to 255 characters (RFC 1035 §3.3). An SPF record may span several strings, joined without spaces (RFC 7208 §3.3). The answer to the TXT lookup should fit in 512 octets. It ought to when the domain name plus the text of all TXT records on that name, not just SPF, comes to under 450 octets (§3.4).
Macros
A domain in an SPF term can contain macros that are filled in from each message (§7). Examples are %{i} for the sending IP, %{s} for the sender, %{d} for the domain being checked, and %{h} for the HELO name. They are mostly used with exists: to build per-sender lookups. A % that doesn’t start a valid macro is a syntax error (§7.3).
Wildcards and subdomains
Each domain name used in mail needs its own SPF record. Your root record doesn’t cover news.example.com. Wildcard records (*.example.com) are discouraged, and they don’t apply to names that already have any records of their own (§3.5).
What the report checks
We read the TXT records at the root of the domain and keep those that start with v=spf1. If there is exactly one, we parse it and then follow every include: and redirect= recursively.
- Lookups are counted for the worst case: a message that matches nothing, which is what forged mail costs. Every lookup term before
allcounts, and aredirect=counts only when the record has noall. Past 40 lookups we stop following and report the count as “at least”. - Macros can’t be filled in without a real message. Each term that uses one counts as one lookup, but we don’t follow it.
- Void lookups are counted when:
- an include target has no TXT records;
- an
aname has neither IPv4 nor IPv6 addresses; - an
mxname has no mail servers; - an
exists:name has no IPv4 address.
| Finding | When we report it | Standard |
|---|---|---|
| No SPF record | The domain has MX records other than a null MX, and no TXT record at the root starts with v=spf1 | RFC 7208 §4.5 |
| The SPF record is pasted incorrectly | No SPF record, but a TXT value contains v=spf1 after other text | §4.5 |
| More than one SPF record | More than one TXT record at the root starts with v=spf1 | §3.2, §4.5 |
| The SPF record has errors | A term is invalid | §4.6 |
| SPF needs too many lookups | More than 10 lookups | §4.6.4 |
| SPF is close to its lookup limit | 8 to 10 lookups | §4.6.4 |
| SPF refers to names that don’t exist | More than 2 void lookups | §4.6.4 |
| SPF depends on a broken record | An include or redirect target without exactly one valid SPF record, or an mx target with more than 10 mail servers | §5.2, §6.1, §4.6.4 |
| SPF includes loop back on themselves | An include or redirect chain returns to a domain already in the chain | §4.6.4 |
| SPF allows anyone to send as you | The effective closing rule (following redirect=) is +all or a bare all | §4.6.2 |
| SPF doesn’t say what to do with other senders | The effective closing rule is ?all | §8.2 |
| SPF has no closing rule | Neither the record nor its redirect= target has an all rule, and nothing it depends on is broken | §4.7 |
| SPF uses the outdated “ptr” rule | Your record contains ptr | §5.5 |
| Part of the SPF record is ignored | Mechanisms follow all | §5.1 |
| Part of SPF could not be checked | A lookup the record depends on didn’t complete | §4.4, §5 |
| SPF could not be read | The TXT lookup for the domain didn’t complete | §4.4 |
How SPF fits Gmail’s, Yahoo’s, and Microsoft’s rules is covered in sender requirements. Domains that send no mail are covered in spoofing protection.
Sources
- RFC 7208, Sender Policy Framework (SPF) for Authorizing Use of Domains in Email, Version 1
- RFC 9989, Domain-based Message Authentication, Reporting, and Conformance (DMARC)
- RFC 7960, Interoperability Issues between DMARC and Indirect Email Flows (§3.2.3 Mailing Lists)
- RFC 5321, Simple Mail Transfer Protocol (§4.4, the Return-Path line)
- RFC 1035, Domain Names, Implementation and Specification (TTL and TXT strings)
- RFC 2308, Negative Caching of DNS Queries
- Google Workspace Help, Set up SPF
- Google Workspace Help, Google IP address ranges for outbound mail servers
- Gmail Help, Email sender guidelines
- Yahoo Sender Hub, Sender best practices
- Microsoft Learn, Set up SPF to identify valid email sources for your Microsoft 365 domain
- Amazon Route 53 Developer Guide, Supported DNS record types (TXT)
- Cloudflare DNS docs, DNS record types (TXT)
- Namecheap Knowledgebase, How do I set up host records for a domain?
Want this checked on your own domain?
Join the waitlist