What Is an SPF Record?
An SPF (Sender Policy Framework) record is a DNS TXT record that specifies which mail servers are authorized to send email on behalf of a domain. Defined in RFC 7208, SPF helps receiving mail servers detect forged sender addresses and is a foundational layer of email authentication alongside DKIM and DMARC.
How SPF Works
When a mail server receives a message claiming to be from [email protected], it performs an SPF check:
- The receiving server extracts the domain from the SMTP envelope sender (the MAIL FROM address, also called the return-path).
- It queries DNS for the TXT record at example.com that begins with
v=spf1. - It evaluates the SPF record's mechanisms against the connecting server's IP address.
- It returns a result: pass, fail, softfail, neutral, or none.
SPF Record Format
An SPF record is a single TXT record published at the domain apex. It starts with the version tag v=spf1 followed by one or more mechanisms and a default qualifier:
v=spf1 ip4:192.0.2.0/24 include:_spf.google.com include:sendgrid.net -all
Common Mechanisms
- ip4 / ip6 -- Authorizes a specific IP address or CIDR range.
- include -- References another domain's SPF record. Used when third-party services (Google Workspace, SendGrid, Mailchimp) send on your behalf.
- a -- Authorizes the IP addresses in the domain's A/AAAA records.
- mx -- Authorizes the IP addresses of the domain's MX record hosts.
- all -- Matches everything. Always used as the final mechanism with a qualifier.
Qualifiers
- + (pass) -- Default. The IP is authorized.
- - (fail) -- The IP is explicitly not authorized. Receivers should reject.
- ~ (softfail) -- The IP is probably not authorized. Receivers should accept but flag.
- ? (neutral) -- No assertion. Treated like no SPF record for that IP.
SPF Evaluation Results
| Result | Meaning |
|---|---|
| Pass | Sender IP matches a mechanism. Message is authorized. |
| Fail | Sender IP does not match, and the record ends with -all. |
| Softfail | Sender IP does not match, and the record ends with ~all. |
| Neutral | Record ends with ?all. No policy assertion. |
| None | No SPF record exists for the domain. |
| PermError | The SPF record is malformed (e.g., exceeds 10 DNS lookup limit). |
| TempError | A transient DNS error prevented evaluation. |
The 10-Lookup Limit
RFC 7208 limits SPF evaluation to 10 DNS lookups (including include, a, mx, redirect, and exists mechanisms). Exceeding this limit produces a PermError, which many receivers treat as a fail. Flattening SPF records (resolving includes to IP addresses) is a common workaround, though it requires maintenance when provider IPs change.
Checking Your SPF Record
Use our SPF check tool to validate your SPF record syntax, count DNS lookups, and verify that your authorized senders are correctly included. SPF alone does not prevent domain spoofing in the visible From header -- that requires alignment with DMARC.
Stay on top of your email infrastructure. Sign up for the InboxTooling newsletter for deliverability tips, tool updates, and best practices.