Guide

SPF Record Setup & Troubleshooting

SPF is the first line of defense in email authentication. Get the syntax right, avoid the 10-lookup limit, and ensure Cyber Defense Agent shows a passing SPF check.

FK

Farhad Mirza Khawar

Founder of HIPAA Agent and Cyber Defense Agent. Compliance infrastructure for SMBs. Sacramento, CA.

2026-05-01

What SPF is and why it matters

Sender Policy Framework (SPF) is a DNS-based email authentication protocol that lets you declare which mail servers are authorized to send email on behalf of your domain. Without SPF, anyone can send email that appears to come from your domain — a technique attackers use for phishing and business email compromise. SPF works by publishing a TXT record in your domain's DNS. When a receiving mail server gets a message claiming to be from your domain, it looks up your SPF record and checks whether the sending server's IP address is listed as authorized. If it's not, the message fails SPF authentication. Cyber Defense Agent verifies SPF as part of every scan. A missing or misconfigured SPF record is flagged as a finding that affects your overall Cyber Defense Score.

SPF syntax and record structure

An SPF record is a DNS TXT record that starts with v=spf1 and ends with an "all" qualifier. Here's the anatomy of a typical SPF record: v=spf1 include:_spf.google.com include:spf.protection.outlook.com ip4:203.0.113.5 -all Key mechanisms: - include: — Authorizes another domain's SPF record (used for third-party services) - ip4: / ip6: — Authorizes specific IP addresses or ranges - a — Authorizes the domain's A record IP - mx — Authorizes the domain's MX record IPs - -all — Hard fail: reject unauthorized senders - ~all — Soft fail: mark but don't reject (less secure) - ?all — Neutral: no policy (defeats the purpose) Always use -all (hard fail) for maximum protection. The ~all soft fail is acceptable during initial setup but should be tightened to -all once you've confirmed all legitimate senders are included.

Common SPF mistakes and the 10-lookup limit

The most common SPF mistakes that Cyber Defense Agent detects: 1. Exceeding the 10-lookup limit — SPF allows a maximum of 10 DNS lookups (include, a, mx, redirect mechanisms). Each "include" triggers additional lookups. Exceeding 10 causes SPF to permanently fail (permerror). Solution: consolidate includes, use ip4/ip6 for static IPs, or use SPF flattening services. 2. Multiple SPF records — You can only have ONE SPF TXT record per domain. Multiple records cause SPF to fail entirely. Combine all mechanisms into a single record. 3. Missing third-party senders — Forgetting to include services like Mailchimp, HubSpot, Salesforce, or your helpdesk platform. Audit all services that send email as your domain. 4. Using +all — The +all mechanism authorizes everyone to send as your domain, completely defeating the purpose of SPF. Never use +all. 5. Not including your email provider — Ensure your primary email platform (Microsoft 365, Google Workspace) is included in your SPF record.

How CDA verifies your SPF record

Cyber Defense Agent performs several SPF checks during each scan: - Presence check: Does an SPF record exist for the domain? - Syntax validation: Is the record properly formatted with v=spf1? - Lookup count: Does the record stay within the 10-lookup limit? - Policy strength: Does the record end with -all (hard fail) or the weaker ~all? - Duplicate detection: Are there multiple SPF records (which cause failure)? After making SPF changes, run a new Cyber Defense Agent scan to verify your configuration. DNS propagation typically takes 15-60 minutes, so wait before rescanning. Pro tip: Use the "dig TXT yourdomain.com" command or an online SPF checker to validate your record before publishing it to DNS.

Key Takeaways

TL;DR

SPF declares which servers can send email as your domain — publish exactly one TXT record.

Stay within the 10 DNS lookup limit or SPF will permanently fail.

Always end your SPF record with -all (hard fail) for maximum protection.

Audit all third-party services that send email as your domain and include them.

Cyber Defense Agent verifies SPF presence, syntax, lookup count, and policy strength.

FAQ

Frequently asked questions

How do I check my current SPF record?

You can check your SPF record using Cyber Defense Agent's scan, or use command-line tools like "dig TXT yourdomain.com" or "nslookup -type=TXT yourdomain.com". Online tools like MXToolbox SPF Lookup also work. Look for a TXT record starting with v=spf1.

What happens if I exceed the 10-lookup limit?

If your SPF record exceeds 10 DNS lookups, it returns a permanent error (permerror) and SPF fails for ALL messages — even from authorized senders. This is equivalent to having no SPF record. Use SPF flattening or consolidate includes to stay under the limit.

Should I use -all or ~all?

Use -all (hard fail) for production. The ~all (soft fail) is acceptable during initial setup to avoid blocking legitimate email while you identify all senders. Once you've confirmed all authorized senders are included, switch to -all for maximum protection.

Get your Cyber Defense Score™ in 60 seconds.

100 tools. No installation. No credit card. Real evidence.