SPF Record: Syntax, Mechanisms, the 10-Lookup Limit, and How It Works
A Sender Policy Framework (SPF) record is a DNS TXT record that lists every mail server and IP address authorized to send email on behalf of your domain. Receiving mail providers check your v=spf1 record during delivery to block spoofed messages from unauthorized servers. The lookup limit of an SPF record is capped at 10 DNS queries.
How Does an SPF Record Check Work During SMTP Delivery?
The Internet Engineering Task Force created Sender Policy Framework (SPF) to supplement the Simple Mail Transfer Protocol (SMTP), which lacks built-in sender authentication of its own. During inbound message delivery, a receiving Mail Transfer Agent (MTA) evaluates sender authorization across 6 sequential evaluation steps during the SMTP session. For high-volume senders, a valid SPF record is part of the mandatory baseline under the Gmail and Yahoo bulk sender requirements alongside DKIM and DMARC.
Receiving mail gateways evaluate sender authorization through 6 sequential operational phases:
- Extract the sender's envelope domain from the SMTP
MAIL FROMcommand (the Return-Path bounce address), falling back to theEHLOorHELOhostname when theMAIL FROMaddress is empty (such as in bounce delivery status notifications). - Record the connecting IPv4 or IPv6 address of the sending mail server that established the TCP port 25 connection.
- Query the authoritative DNS nameserver of the envelope domain for a TXT resource record (Type 16) beginning with the exact version tag
v=spf1. - Evaluate each mechanism in the published record sequentially from left to right (ip4, ip6, include, a, mx, all), resolving up to 10 nested DNS queries until a mechanism matches the connecting server IP address.
- Assign one of the 7 official evaluation results (Pass, Fail, SoftFail, Neutral, None, TempError, or PermError) based on the prefix qualifier (+, -, ~, or ?) preceding the matching mechanism.
- Write the authentication verdict into the message's
Received-SPFandAuthentication-Resultsheaders and pass the outcome to the receiver's DMARC policy engine.
Early implementations defined a dedicated SPF DNS resource record (Type 99), which the IETF formally deprecated in 2014; all modern SPF records publish exclusively as DNS TXT records. Domain administrators can inspect live domain records using the SPF Record Checker.
What Is the Syntax of an SPF Record? (Version, Mechanisms, Qualifiers, and Modifiers)
An SPF record consists of a single plain-text DNS TXT string starting with v=spf1 followed by space-separated mechanisms, prefix qualifiers, and optional modifiers.
A standard multi-sender SPF configuration combines IP ranges and provider includes in a single string:
v=spf1 ip4:192.0.2.0/24 include:_spf.google.com include:sendgrid.net -all Mechanisms define which IP addresses or hostnames are authorized to send mail, and each mechanism carries a specific DNS query cost. The table below lists the 8 core SPF mechanisms and modifiers by syntax example and DNS lookup cost.
| Mechanism | Syntax example | DNS lookups consumed |
|---|---|---|
| include | include:_spf.google.com | 1 (plus nested includes) |
| a | a:mail.example.com | 1 |
| mx | mx:example.com | 1 toward the 10-lookup limit (up to 10 MX A/AAAA sub-lookups allowed) |
| ptr | ptr:example.com | 1 (deprecated, avoid) |
| exists | exists:verify.example.com | 1 |
| redirect | redirect=example.com | 1 (replaces the record) |
| ip4 / ip6 | ip4:192.0.2.0/24 | 0 |
| all | ~all or -all | 0 |
The operational split between 0-lookup terms and DNS-querying mechanisms governs record efficiency. Terms such as the v=spf1 version tag, ip4, ip6, and all consume 0 DNS lookups, whereas include, a, mx, ptr, exists, and redirect= each consume 1 DNS lookup (plus any nested lookups inside an include target). The SPF specification explicitly deprecates the ptr mechanism because reverse DNS lookups impose heavy query latency and fail unpredictably under high mail volume. Administrators can review macro expansion and advanced syntax in the SPF Record Syntax guide or inspect mechanism behavior in SPF Mechanisms Explained.
What Are the 4 SPF Qualifiers (+, -, ~, ?) and 2 Modifiers?
An SPF qualifier is a 1-character prefix (+, -, ~, or ?) placed before a mechanism that instructs the receiving server how to classify a matching IP address.
The SPF standard defines 4 qualifier symbols:
- + (Pass): Designates authorized senders. The plus sign is the implied default when omitted before a mechanism (for example,
include:_spf.google.comfunctions identically to+include:_spf.google.com). - - (Fail / HardFail): Designates unauthorized senders and instructs receiving servers to reject non-matching messages outright (such as
-all). - ~ (SoftFail): Designates unauthorized senders while instructing receiving servers to accept the message and mark it as suspicious or deliver it to spam (such as
~all). - ? (Neutral): Asserts neither authorization nor rejection, prompting receiving servers to process the message without positive or negative SPF weighting. Setting
+allcreates a critical vulnerability that authorizes every IP address worldwide to send mail for the domain.
Modifiers provide secondary routing instructions. The redirect= modifier replaces the current evaluation with the target domain's SPF record, enabling organizations to manage multiple domains from a shared central policy. The exp= modifier references a DNS TXT record containing a custom explanation string returned to rejected senders. Administrators evaluating terminal enforcement rules can consult the SPF Softfail vs Hardfail technical comparison.
What Are the 7 Official SPF Evaluation Results?
The SPF specification defines 7 deterministic SPF evaluation outcomes (Pass, Fail, SoftFail, Neutral, None, TempError, and PermError) that receiving mail servers record in the Authentication-Results header. The table below maps each of the 7 SPF results to its trigger condition, common receiver disposition, and DMARC impact.
| Result | Meaning | Typical receiver action |
|---|---|---|
| Pass | IP is authorized by the record | Accept toward DMARC alignment |
| Fail (-all) | IP is explicitly not authorized | Reject, or mark per policy |
| SoftFail (~all) | IP is probably not authorized | Accept but flag as suspicious |
| Neutral (?) | Record asserts nothing about the IP | Treat like no SPF |
| None | No SPF record published | No SPF evaluation possible |
| TempError | DNS timeout or SERVFAIL during evaluation | Defer with 4xx temporary rejection (sender retries later) |
| PermError | Record is malformed or exceeds limits | Permanent evaluation failure |
Differentiating between transient TempError and permanent PermError determines the correct troubleshooting response. A TempError represents a temporary DNS infrastructure failure (such as a nameserver timeout or SERVFAIL response), prompting receiving MTAs to issue a 4xx temporary rejection (such as 451 4.4.3) so the sending server retries delivery automatically. Conversely, a PermError indicates that the published SPF record is structurally invalid (such as exceeding 10 DNS lookups or publishing duplicate v=spf1 records), preventing authentication entirely until corrected in DNS. Administrators can diagnose syntax and resolution errors using the SPF PermError and SPF TempError references.
What Are the 4 Technical Limits of an SPF Record? (The 10-Lookup Rule and Beyond)
Email standards enforce 4 strict technical limits on every SPF record: the single-record rule, the 10-DNS-lookup limit, the 2-void-lookup limit, and the 255-character TXT string limit.
Receiving mail transfer agents enforce 4 strict protocol constraints during evaluation:
- The Single SPF Record Rule: The SPF specification restricts each domain or subdomain to a single TXT record starting with
v=spf1. Publishing two or more separatev=spf1records causes receiving servers to abort evaluation immediately and return PermError; administrators merge multiple sending services into a single string. - The 10-DNS-Lookup Rule: Mail servers cap SPF evaluation at 10 DNS queries across all top-level and recursively nested include, a, mx, ptr, exists, and redirect= terms. Receiving MTAs enforce this cap to prevent malicious actors from using forged SPF records as a DNS amplification Denial-of-Service (DoS) weapon; the 11th lookup triggers an immediate PermError.
- The 2-Void-Lookup Rule: Receivers enforce a secondary limit of 2 void lookups: queries that return an empty answer (0 records) or NXDOMAIN, which frequently occurs when decommissioned third-party email providers expire.
- The 255-Character String Limit: A single DNS TXT character-string contains a maximum of 255 ASCII bytes. Authoritative DNS servers split TXT records exceeding 255 ASCII characters into multiple quoted strings within the same TXT record (which DNS resolvers concatenate without spaces), keeping total UDP payload size under 450 bytes to avoid TCP fallback.
Administrators can prevent PermErrors by managing record complexity through 3 strategies: removing deprecated third-party services, delegating distinct mail streams to dedicated subdomains (such as mail.example.com, which receives an independent 10-lookup quota), or replacing dynamic includes with direct CIDR ranges. Detailed remediation workflows are available in The SPF 10-Lookup Limit Explained, the automated SPF Flattener tool, and the SPF Record Too Long guide.
Why Can SPF Pass While DMARC Fails? (Return-Path vs Header From Alignment)
An email passes SPF authentication yet fails DMARC when the envelope Return-Path bounce address checked by SPF does not match the visible From: address displayed to the recipient.
Every standard email message carries 2 distinct sender identities: the envelope Return-Path address used by mail servers to route delivery status notifications and evaluate SPF, and the visible From: address presented to users in mail clients. An attacker authenticates an external domain (Return-Path: bounce@attacker-mailer.net) to pass SPF while forging From: ceo@yourcompany.com in the visible header when a domain lacks a DMARC policy.
The DMARC protocol closes this security loophole by mandating SPF Identifier Alignment. Under relaxed alignment (aspf=r), the organizational domain of the Return-Path matches the visible From: domain (for example, bounces.example.com aligns with example.com). Under strict alignment (aspf=s), the hostnames match character-for-character. Administrators can review alignment mechanics in the DMARC and DMARC Alignment guides.
The technical separation between envelope and display identities exposes a widespread industry error. Email platforms that route bounces through their own organizational domain (including Mailchimp via mcsv.net and default Amazon SES via amazonses.com) transmit email using a vendor domain in the envelope Return-Path by default. A receiving mail server queries the ESP's SPF record instead of your domain's SPF record when evaluating messages sent with a third-party Return-Path. Adding vendor include mechanisms to your root domain's SPF record without configuring a custom Return-Path subdomain consumes DNS lookups without achieving DMARC alignment.
Why Does Email Forwarding Break SPF (And How Do DKIM and ARC Fix It)?
Email forwarding breaks SPF authentication because an intermediary forwarding server retransmits the message from its own IP address while preserving the original sender's Return-Path domain.
An automated email forwarder breaks SPF authentication if an intermediary server relays messages to an external mailbox. The connecting IP address belongs to the forwarding server (university.edu) rather than the original sender (company.com) when the final recipient server receives a forwarded message. Destination mail servers evaluate the original domain's SPF policy against the forwarding IP, find no authorization entry, and produce an SPF Fail result.
Modern mail ecosystems preserve delivery across indirect mailflows through 3 complementary standards:
- DKIM: Cryptographic signatures attach to email headers and remain intact during transmission across intermediary servers, allowing DMARC to pass via DKIM alignment even when SPF evaluation fails. Review signature architecture in DKIM Explained and SPF vs DKIM.
- Sender Rewriting Scheme (SRS): The forwarding server rewrites the envelope Return-Path address to an intermediary address on the forwarding domain, ensuring SPF evaluates the forwarding server's authorized IP address on subsequent hops.
- Authenticated Received Chain (ARC): Intermediary forwarders and mailing lists attach cryptographically signed validation headers preserving original authentication verdicts across hops, detailed in ARC Explained.
Deploying DKIM cryptographic signing alongside SPF ensures that legitimate forwarded emails survive intermediary hops and pass DMARC alignment checks.
How Do You Create, Publish, and Verify an SPF Record? (4 Steps)
To create and publish a valid SPF record in DNS, complete 4 sequential configuration and verification steps.
Deploying a production SPF policy follows 4 sequential stages:
- Inventory every authorized outbound mail server and third-party Email Service Provider (ESP) that transmits email using your domain in the Return-Path (including Google Workspace, Microsoft 365, SendGrid, Postmark, and dedicated web server IPs).
- Construct a single
v=spf1TXT string combining authorized IP ranges and vendor include mechanisms, ending with~all(during initial deployment with DMARC reporting) or-all(for strict enforcement), orv=spf1 -allfor parked domains that send zero email. - Publish the text string as a DNS TXT record at your authoritative DNS provider (@ for the root domain, or the subdomain hostname for isolated sending streams) with a Time to Live (TTL) of 3600 seconds.
- Validate the live DNS publication using the SPF Record Checker or by executing
dig +short TXT example.comto verify single-record compliance, syntax validity, and lookup consumption within the 10-lookup threshold.
Administrators can implement common deployment patterns using standard configuration templates:
Google Workspace + SendGrid:
v=spf1 include:_spf.google.com include:sendgrid.net ~all Microsoft 365:
v=spf1 include:spf.protection.outlook.com -all Parked Non-Sending Domain:
v=spf1 -all Additional configuration examples and step-by-step guides are detailed in How to Create an SPF Record and SPF Record Examples, or generated automatically using the SPF Record Generator.
Frequently asked questions
Can a domain have more than one SPF record?+
No, the SPF specification strictly requires exactly one SPF TXT record per domain or subdomain. Publishing two or more v=spf1 records causes receiving mail servers to abort evaluation and return a PermError.
Should I end my SPF record with ~all or -all?+
Use ~all (SoftFail) during initial deployment while auditing senders via DMARC aggregate reports, and switch to -all (HardFail) once every legitimate sending service is verified and aligned.
How do I protect a parked domain that never sends email?+
Publish the null SPF record v=spf1 -all at the domain apex alongside a v=DMARC1; p=reject; record at _dmarc to instruct receiving mail servers to reject all mail claiming to originate from that domain. In real-world security audits, we recommend locking down unused defensive registrations immediately because attackers frequently impersonate dormant sister domains lacking published authentication records.
Which SPF mechanisms count toward the 10-DNS-lookup limit?+
Six SPF terms count toward the 10-DNS-lookup limit: include, a, mx, ptr, exists, and the redirect= modifier (plus any nested lookups inside included domains). The v=spf1, ip4, ip6, and all mechanisms require 0 DNS lookups. In practice, the most common mistake organizations make is chaining multiple third-party marketing includes without monitoring total query depth, triggering permanent evaluation errors (PermError) and silent message drops.
Last verified: 2026-11-28