Join our Newsletter — 33% off our NHI Course
Home› Guides› SPF Record Syntax and the 10 DNS Lookup…
Guide Email & Communications Security

SPF Record Syntax and the 10 DNS Lookup Limit: Writing Records That Stay Valid

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 27 November 2026 15 min read
On this page

Most broken SPF records are not wrong about which servers may send mail, they are invalid because they ask receivers to do more DNS work than RFC 7208 allows. Every new mail platform, CRM or ticketing tool tends to add another include:, and once nested includes push evaluation past ten DNS-querying terms the result is permerror, which DMARC treats as an SPF failure. This guide is a syntax and limits reference for email and DNS administrators: what each mechanism and modifier costs, how the 10 lookup and void lookup limits are counted, how to cut lookups without creating new risk, and how to watch the result in DMARC reports. For how SPF fits with DKIM and DMARC overall, see the DMARC, SPF and DKIM Guide.

Key takeaways

  • Ten terms, not ten includes. RFC 7208 section 4.6.4 counts include, a, mx, ptr, exists and redirect, including every one found inside nested includes, and the total must not exceed 10.
  • Some terms are free. ip4, ip6, all and the exp modifier cause no DNS query during evaluation and do not count.
  • Void lookups break records quietly. Receivers should return permerror after more than two lookups that return no answer or NXDOMAIN, which often comes from stale includes for retired vendors.
  • One record per name. Two v=spf1 TXT records at the same name produce permerror before any mechanism is evaluated.
  • Flattening is a trade, not a fix. Replacing includes with IP ranges saves lookups but moves the job of tracking vendor IP changes to you; Microsoft advises against flattening its own include.

SPF record anatomy

An SPF record is a single DNS TXT record published at the domain used in the SMTP MAIL FROM (and optionally HELO) identity. It starts with the version tag v=spf1, followed by space-separated terms that receivers evaluate left to right. The first mechanism that matches decides the result; modifiers apply only as described below.

A typical record looks like this:

1 Sample only, based on the public documentation cited. Assess it independently against the current official documentation, test outside production and back up first.

Sample 1
example.com.  TXT  "v=spf1 ip4:192.0.2.0/24 include:_spf.mailvendor.example mx -all"
  • Version: v=spf1 must come first. Records without it are ignored as SPF.
  • Mechanisms: ip4:192.0.2.0/24, include:... and mx each describe a set of authorised hosts.
  • Default: -all matches everything not already matched and returns fail.
  • One record: RFC 7208 section 3.2 says a domain must not publish multiple records that would cause more than one to be selected, and section 4.5 makes more than one record a permerror. Microsoft's SPF documentation gives the same rule for each domain and subdomain.
  • Size: RFC 7208 section 3.4 advises keeping the record small enough that the DNS answer fits in 512 octets, and keeping the name plus all TXT records of that type under 450 octets so the reply fits in UDP. A single TXT character-string is limited to 255 octets in DNS, so long records are split into several quoted strings that receivers join without spaces.
  • Scope: a record covers only the exact name it is published at. Microsoft notes that the record for the parent domain does not cover a subdomain such as marketing.example.com; each sending subdomain needs its own record.

RFC 7208 is a Proposed Standard (April 2014) that obsoletes RFC 4408 and has since been updated by RFC 7372, RFC 8553 and RFC 8616. Publish SPF as a TXT record only: RFC 7208 retired the separate SPF record type.

Mechanisms and qualifiers reference

RFC 7208 section 5 defines eight mechanisms and section 6 defines two modifiers. The lookup cost column is what each term adds to the section 4.6.4 counter.

TermTypeWhat it matchesCounts towards 10Notes
allMechanismAlways matchesNoPut last. Anything after it is never evaluated.
include:<domain>MechanismMatches if the target domain's SPF evaluation returns passYes, 1 plus every counted term inside the targetThe main source of over-limit records. A target with no SPF record gives permerror.
a / a:<domain>MechanismSender IP equals an A or AAAA record of the domainYes, 1Optional CIDR suffix, e.g. a/24.
mx / mx:<domain>MechanismSender IP equals an address of one of the domain's MX hostsYes, 1Each MX evaluation must not query more than 10 address records, or the result is permerror.
ptrMechanismValidated reverse DNS name ends in the domainYes, 1RFC 7208 section 5.5: should not be published. Slow and unreliable; remove it.
ip4:<net>MechanismSender IPv4 in the rangeNoUse CIDR, e.g. ip4:198.51.100.0/24.
ip6:<net>MechanismSender IPv6 in the rangeNoInclude IPv6 ranges for any sender that delivers over IPv6.
exists:<domain>MechanismMatches if an A record exists for the (usually macro-expanded) nameYes, 1Used by some large senders with macros. Check what the macro reveals before adopting.
redirect=<domain>ModifierIf no mechanism matched, evaluation continues with the target's recordYes, 1Ignored if the record contains all. At most once per record.
exp=<domain>ModifierOn fail, supplies an explanation string from a TXT recordNoRarely used in practice. At most once per record.

Each mechanism can carry a qualifier prefix that sets the result when it matches. With no prefix the qualifier is +.

QualifierResult on matchTypical useEffect under DMARC
+ (default)passAuthorised sendersCounts as SPF pass if the MAIL FROM domain aligns with the From domain
-fail-all once every sender is listedSPF fail; some receivers reject at SMTP time before DMARC runs
~softfail~all while inventory is incompleteNot a pass, so DMARC treats it as SPF not aligned and passing
?neutralTesting onlyNot a pass; Microsoft does not recommend ?all in production

The other evaluation results defined in RFC 7208 section 2.6 are none (no record), temperror (a transient DNS problem, retry may succeed) and permerror (the published record cannot be interpreted and needs fixing by the DNS operator).

What counts towards the 10 lookup limit

RFC 7208 section 4.6.4 says implementations must limit the total number of include, a, mx, ptr and exists mechanisms and redirect modifiers to 10 during an evaluation, and return permerror if the limit is exceeded. The count is for the whole evaluation, so every counted term inside every nested include is added to your total.

Worked count

Sample 1
v=spf1 ip4:192.0.2.10 include:spf.protection.outlook.com include:_spf.crm.example include:mail.ticketing.example mx -all
  1. ip4 and -all: 0.
  2. mx: 1.
  3. Each include: 1 each, so 3.
  4. Inside each include: count its own include, a, mx, ptr, exists and redirect terms, recursively. If the CRM include itself includes three regional records, that is 3 more.

The total is the number you must keep at 10 or below. Vendors change their own records without notice, so a record that counted 9 last quarter can count 11 today with no change on your side.

Sub-limits that also produce errors

LimitSourceBehaviour when exceeded
10 DNS-querying terms per evaluationRFC 7208 s4.6.4permerror
10 address lookups per mx evaluationRFC 7208 s4.6.4permerror
10 names per ptr evaluationRFC 7208 s4.6.4Names after the first 10 are ignored, no error
2 void lookupsRFC 7208 s4.6.4 (SHOULD)permerror
More than one SPF record at a nameRFC 7208 s4.5permerror
redirect or exp more than onceRFC 7208 s6Syntax error, permerror

Microsoft's documentation adds a practical point: receivers stop at the first matching mechanism, so some mail still passes when a record is over the limit. Over-limit records can therefore go unnoticed for weeks.

The void lookup limit and permerror

A void lookup is a DNS query made during SPF evaluation that returns either no answer records or NXDOMAIN. RFC 7208 says implementations should limit void lookups to two and return permerror when more occur. The limit exists to stop records that point at names which no longer exist from generating needless DNS load.

Common causes:

  • Retired vendors: an include: for a marketing or helpdesk platform you stopped using, whose SPF name has since been deleted.
  • Typos: include:spf.protection.outlook.co or a missing underscore in _spf.
  • Bare a or mx on a name with no records: for example mx on a sending-only subdomain that has no MX records.

Void lookups also count towards the 10 term limit, so a stale include costs you twice. A dangling include also has a security angle: if the old vendor domain lapses and is re-registered by someone else, they control part of your SPF policy. Remove includes as part of vendor offboarding, the same way you remove the vendor's API keys and accounts.

Reducing lookups safely

Work through these options in order. The earlier ones remove lookups without adding maintenance.

  1. Remove what is not used. Delete includes for retired services, ptr and any a or mx that does not correspond to a host that actually sends mail as this domain. DMARC aggregate reports tell you which sources really send.
  2. Replace your own hosts with ip4 and ip6. Your own outbound relays rarely change address; listing their ranges costs nothing.
  3. Move third-party senders to subdomains. Give the marketing platform news.example.com and the ticketing tool support.example.com as the MAIL FROM domain, each with its own SPF record and its own 10 lookup budget. Microsoft recommends this for senders you do not control, so their problems do not affect the main domain. Under DMARC relaxed alignment a subdomain MAIL FROM still aligns with the organisational domain in the From header.
  4. Prefer DKIM for platforms that sign. If a vendor signs with an aligned DKIM key for your domain, DMARC can pass on DKIM alone. RFC 9989 notes that domain owners can rely on DKIM-only DMARC, while recommending both. The vendor's include may then belong on a subdomain or not be needed at all.
  5. Flatten only stable vendor ranges. Flattening replaces an include with the IP ranges it resolves to.

Flattening: when and when not

ApproachLookups savedRiskFits
Manual flatteningAll for that includeVendor adds IPs, your mail from those IPs fails SPF until you noticeSmall vendors with documented, rarely changing ranges
Automated flattening serviceAllThe service now controls your SPF record; its outage or error affects all mailLarge estates that cannot use subdomains, with change alerts
Subdomain per senderAll, from the main recordMore DNS records to manageMost organisations; the preferred route
DKIM-only for a senderAll for that senderMail fails DMARC if the DKIM signature breaks in forwarding or the key is rotated badlyVendors with aligned DKIM support

Microsoft advises not flattening include:spf.protection.outlook.com because its sending IPs change frequently, and asks that anyone who flattens documents the change, monitors vendor IP updates, reviews at least quarterly and tests after each change. Treat flattened records as configuration with an owner, a review date and a change record, under your normal change control.

Decision guidance by organisation size

  • Small organisations with one mail platform and one or two senders usually fit inside the limit with includes and -all. The main job is removing stale includes during vendor changes.
  • Mid-sized organisations with five to ten SaaS senders should move bulk and transactional senders to subdomains before they reach eight counted terms, leaving headroom for vendor changes.
  • Large organisations with many business units should run SPF as a managed service: a register of sending sources, an owner per subdomain, automated lookup counting in CI for DNS changes, and alerts on DMARC SPF permerror rates.

Testing and monitoring with DMARC reports

SPF records fail silently from the sender's view. DMARC aggregate reports are the cheapest way to see what receivers actually computed. DMARC itself is now specified in RFC 9989 (Proposed Standard, May 2026), which obsoletes RFC 7489 and RFC 9091; see the DMARCbis Changes Guide. Under RFC 9989, DMARC uses SPF results for the MAIL FROM identity only, not HELO, and the SPF-authenticated domain must align with the From domain.

Rollout and change procedure

  1. Inventory: collect two to four weeks of DMARC aggregate reports at p=none and list every source IP and MAIL FROM domain that sends as your domain.
  2. Draft and count: write the new record, expand every include recursively with dig TXT and count the terms by hand or with a checker. Target 8 or fewer for headroom. See the DNS Investigation with dig and nslookup Guide.
  3. Lower TTL first: reduce the TXT record TTL a day ahead so a bad change can be reverted quickly.
  4. Publish with ~all if inventory is uncertain, then watch reports for a full business cycle, including month-end and marketing sends.
  5. Move to -all when reports show no legitimate source failing. Microsoft recommends -all with DKIM and DMARC. RFC 9989 notes that a hard fail can lead some receivers to reject before DMARC is evaluated, which also bypasses a DKIM pass, so make sure every legitimate source either passes SPF or uses its own subdomain.
  6. Roll back by republishing the previous record text, which you keep in version control with the change ticket.

What to monitor

  • SPF result by source: aggregate report rows where spf result is permerror or temperror.
  • Unknown sources passing SPF: an IP passing SPF that you do not recognise means a range in an include is broader than you thought.
  • Lookup count: a scheduled job that expands the record daily and alerts above 8, because vendor records change underneath you.
  • Record changes: DNS change logs for TXT records at sending names. See the Authoritative DNS and Registrar Account Security Guide.

Metrics

MetricTarget
Counted SPF lookups per sending domain (fully expanded)8 or fewer
Share of DMARC-reported mail with SPF permerror0%
Legitimate sources passing aligned SPF or aligned DKIM100%
Sending domains ending in -all, plus non-sending domains with v=spf1 -all100%
Days from vendor offboarding to include removalUnder 30

For per-message diagnosis of a failing record, see the DMARC, SPF and DKIM Failure Troubleshooting Guide.

Common failure patterns

  • Two SPF records: a new vendor's onboarding guide says "add this TXT record" and someone adds a second v=spf1 record instead of merging. Every message gets permerror.
  • Include creep: each team adds its SaaS sender to the main domain until nested includes exceed 10. Mail from the sender listed last starts failing first.
  • Stale includes: retired platforms left in the record create void lookups and a takeover path if their domain lapses.
  • Flattened and forgotten: a flattened vendor range drifts out of date and a share of that vendor's mail fails SPF months later.
  • Parked domains with no record: domains that never send mail but publish nothing are easy to spoof. Publish v=spf1 -all and a DMARC p=reject record on them, as Microsoft's guidance describes.
  • Using +all or ?all to "fix" failures: +all authorises every IP on the internet and removes SPF's value entirely.

Framework mapping

FrameworkReferenceHow SPF hygiene supports it
NIST CSF 2.0PR.PS-01SPF records managed as configuration with change control
NIST CSF 2.0DE.CM-01DMARC report monitoring of email authentication results
NIST SP 800-53 Rev 5SI-8 Spam ProtectionSender authentication supports receivers' spam and spoofing protection
NIST SP 800-177 Rev 1Trustworthy EmailRecommends SPF with DKIM and DMARC for sending domain authentication
CIS Controls v8.1Control 9 Email and Web Browser ProtectionsValid SPF and DKIM underpin DMARC enforcement against email threats
MITRE ATT&CKT1684.002 Email Spoofing; T1566 PhishingEnforced SPF with DMARC limits direct spoofing of your domains

Practitioner checklist

  • Confirm exactly one v=spf1 TXT record at each sending name and subdomain.
  • Expand every include recursively and keep the counted total at 8 or fewer.
  • Remove ptr, stale includes and any a or mx that does not send mail.
  • Check for void lookups (NXDOMAIN or empty answers) and fix them before they exceed two.
  • Move third-party senders to their own subdomains with separate SPF records.
  • Flatten only stable vendor ranges, with an owner, a quarterly review and change alerts; never flatten frequently changing provider includes.
  • Publish v=spf1 -all on every domain and subdomain that sends no mail.
  • Move from ~all to -all once DMARC reports show every legitimate source passing.
  • Keep SPF records in version control and schedule a daily lookup-count check with alerting.
  • Add include removal to the vendor offboarding checklist.

Standards and references

Related NHI Mgmt Group resources: DMARC, SPF and DKIM Guide · DMARC, SPF and DKIM Failure Troubleshooting Guide · DMARCbis Changes Guide · Email Authentication Checklist · DNS Security Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.