What is SPF?
SPF (Sender Policy Framework) is a DNS-based email authentication standard that lets domain owners specify which mail servers are authorized to send email on their behalf. Published as a DNS TXT record at the domain root, SPF gives receiving mail servers a way to verify that incoming email claiming to be from your domain actually came from a server you authorized.
When an attacker tries to send spoofed email using your domain, the receiving server queries your SPF record. If the attacker's server IP is not listed and your record ends with -all, the message is marked as a failure. This prevents unauthorized servers from successfully impersonating your domain — but only at the envelope (Return-Path) level. For full spoofing protection against the visible From address, SPF must be paired with DMARC.
Check your SPF record now: Run a free SPF validator on your domain →
Anatomy of an SPF record (v=spf1 syntax)
Every SPF record begins with v=spf1, identifying it as an SPF policy. After the version tag come mechanisms and qualifiers:
example.com. IN TXT "v=spf1 ip4:192.0.2.0/24 include:_spf.google.com include:sendgrid.net -all"
| Part | Meaning |
|------|---------|
| v=spf1 | Version identifier — required |
| ip4:192.0.2.0/24 | Authorize this IP range directly |
| include:_spf.google.com | Pull in Google Workspace's authorized IPs |
| include:sendgrid.net | Pull in SendGrid's authorized IPs |
| -all | Hard fail — reject all other senders |
SPF is evaluated left to right. The first matching mechanism wins. If no mechanism matches, the all qualifier at the end determines the result.
SPF mechanisms: include, a, mx, ip4, ip6, ~all, -all
include: — the most common mechanism. Delegates trust to another domain's SPF record. Each include: consumes one DNS lookup. Use for cloud email providers (Google Workspace, Microsoft 365, SendGrid, Mailchimp).
ip4: / ip6: — authorizes specific IP addresses or CIDR ranges directly. Does not consume a DNS lookup. Preferred for servers with static IPs because it is explicit, fast to evaluate, and does not create a lookup chain.
a — authorizes the IP addresses behind the domain's A record. Consumes one DNS lookup. Use sparingly.
mx — authorizes the domain's MX (mail exchanger) hosts. Consumes one lookup plus one per MX record. Rarely needed for outbound authorization.
~all (softfail) — non-matching senders are marked as suspicious but delivered. The legacy default. Use -all instead for cleaner enforcement.
-all (hardfail) — non-matching senders are definitively unauthorized. Receiving servers should reject or quarantine. The recommended ending for all production SPF records.
+all (pass all) — authorizes every mail server on the internet. Never use this. It completely defeats the purpose of SPF.
The 10-DNS-lookup limit (and how to fix it)
RFC 7208 caps SPF processing at 10 DNS lookups. Each include:, a, mx, exists, and redirect mechanism counts as one lookup. If your record exceeds this limit, receivers return PermError and SPF fails entirely — even for legitimate mail.
Why this happens: Organizations accumulate email providers over years — a CRM tool, a transactional mailer, a marketing platform, a helpdesk ticketing system. Each adds an include:. After several vendor changes, the record may have 15+ lookups with half of them pointing to services no longer in use.
How to fix it:
- Audit your current lookup count with an SPF checker tool
- Remove all
include:entries for vendors no longer sending your email - Replace
include:entries withip4:where the provider uses static IP ranges - Use SPF flattening only as a last resort (see below)
SPF flattening explained
SPF flattening is the process of replacing recursive include: chains with the actual resolved IP addresses (ip4: entries). This eliminates DNS lookups and keeps the record within the 10-lookup limit.
The tradeoff: Once flattened, you own the update cycle. When Google Workspace, SendGrid, or any included provider changes their IP ranges (which happens regularly), your flat SPF record becomes stale — and legitimate mail starts failing.
Flattening is appropriate when you have exhausted other options. If you flatten, you must implement automated monitoring that detects when provider IPs change and alerts you to update your record.
Common SPF errors and how to debug them
Multiple SPF records: Only one v=spf1 record is allowed per domain. Multiple records cause PermError immediately. Merge them into a single record.
PermError from too many lookups: Count your lookups. Remove stale providers. Replace include: with ip4: where possible.
SPF passes but DMARC fails: SPF only checks the envelope sender (Return-Path). If the Return-Path domain does not align with the visible From domain, SPF pass does not satisfy DMARC. This is a DMARC alignment issue, not an SPF error.
Forwarding failures: Forwarded email fails SPF because the forwarding server IP is not in your record. This is expected behavior. DKIM authentication survives forwarding; SPF does not. Ensure DKIM is properly configured so forwarded mail can still satisfy DMARC.
Stale includes: The include:_spf.salesforce.com in your record authorizes every IP Salesforce uses globally. If you stopped using Salesforce three years ago, remove the include — it is an unnecessary attack surface.
SPF vs DMARC alignment
SPF can pass and still contribute nothing to DMARC protection if the authenticated domain does not align with the visible From domain. Consider this scenario: you use a shared email platform, SPF passes using the platform's Return-Path domain, but your From address is @yourcompany.com. SPF passes, DMARC alignment fails.
This is why teams often believe SPF is healthy while DMARC aggregate reports still show failures. SPF should be reviewed as one identity layer inside a complete DMARC authentication chain — not as a standalone checkbox.
How to publish your SPF record
Technical Architecture
SPF operates entirely at the DNS level during the SMTP transaction:
- Envelope Extraction: The receiving MTA extracts the domain from the
Return-Path(MAIL FROM) envelope — often different from the user-visibleFrom:header. - DNS Query: The receiver queries for a TXT record at that domain starting with
v=spf1. - Mechanism Evaluation: Mechanisms are evaluated left to right to build the authorized IP list.
- IP Matching: The connecting server's IP is compared against the authorized list.
- Qualifier Application: The match result is combined with the qualifier (
-all,~all, etc.) to produce the final SPF result.
cyberfurl.com. IN TXT "v=spf1 ip4:192.0.2.0/24 include:_spf.google.com include:sendgrid.net -all"
Common Misconfigurations
- The 10-Lookup Limit (RFC 7208): Exceeding 10 lookups causes
PermError, failing SPF for all mail - Multiple SPF Records: Two
v=spf1records = immediatePermErrorfor all receivers - Stale Vendor Includes: Legacy
include:entries for discontinued SaaS tools create shadow-IT abuse vectors - Over-reliance on
+all:+allauthorizes the entire internet — never use it - Using
mxexcessively: Each MX record behindmxadds another lookup to the count
Security Risks
- Return-Path Spoofing: Without
-all, spam filters cannot classify non-matching senders as unauthorized - Shadow IT Abuse: Stale
include:entries let attackers use your legacy SaaS tools to send authenticated mail as your domain - Deliverability Breakage: A broken SPF record (PermError from too many lookups) causes legitimate mail — password resets, invoices, MFA tokens — to fail globally
Compliance Impact
- NIST Guidelines: Recommend strict SPF as part of anti-phishing and malware defense
- HIPAA/GLBA: Require controls over unauthorized communication channels — an open SPF record violates baseline secure communication requirements
- Vendor Risk Management: Enterprise buyers scan SPF records during security reviews. An invalid or permissive SPF record stalls procurement
Best Practices for SPF in 2025/2026
- Use ip4/ip6 over includes where possible: Direct IP authorization is cheaper (no lookups) and more explicit
- Quarterly vendor audit: Remove every
include:for tools your organization no longer uses - Always end with -all: Explicit hard-fail signals clear intent to receivers and reduces ambiguity
- Pair with DMARC: SPF alone does not protect the visible
From:address — always pair with DMARC enforcement
Tools to check your SPF
Use the CyberFurl SPF validator as your primary SPF checker to inspect the live record on any domain. A comprehensive SPF lookup shows the full mechanism chain, lookup count, resolved IPs, and any syntax errors. After fixing your record, re-run the SPF record checker to confirm the corrected version is clean and within the lookup limit. For continuous monitoring that alerts on drift, unauthorized senders, and record changes, combine the SPF checker with Email Security monitoring.
How CyberFurl Helps
Automated monitoring. Zero manual work.
CyberFurl continuously monitors your public SPF record and DMARC aggregate reports together, automatically detecting 10-lookup limit violations, syntax errors, unauthorized sender IPs, and stale vendor includes. When a new ESP is added without updating SPF, CyberFurl flags the misalignment in DMARC reports before it becomes a deliverability incident.
