SPF Syntax Validation

What This Check Does

The SPF Syntax Validation check performs a comprehensive analysis of your SPF record structure against RFC 7208. It examines mechanism ordering, directive validity, DNS lookup counts, macro syntax, IP address formatting, and other structural requirements that affect whether your SPF record will work as intended.

DNS Spy parses each term in your SPF record and evaluates it against the RFC specification. Issues are categorized as errors (which cause the check to fail) or warnings (informational findings reported alongside a passing result).

Why It Matters

An SPF record can look perfectly reasonable at first glance and still be fundamentally broken. The most dangerous syntax errors are the ones that fail silently — your SPF record exists, it parses without obvious errors, but it does not do what you intended.

The most common and damaging example is placing the "all" mechanism in the wrong position. Per RFC 7208, the "all" mechanism matches everything, so any terms that appear after it are silently ignored by receiving mail servers. If your IT team adds a new service's SPF mechanism after the "all" directive, that service will never be authorized — even though the record looks correct.

Other critical syntax issues include exceeding the 10 DNS lookup limit (which causes a PermError on all SPF evaluations), using deprecated mechanisms that may not be supported by all receivers, and invalid IP addresses or CIDR notation that silently fail to match.

NIST SP 800-81, Section 6, emphasizes correct email authentication configuration. DNS Spy's syntax validation goes beyond simply checking for SPF presence — it verifies the record will actually work as your team intended.

NIST SP 800-81 Compliance

Section 6 of the NIST Secure DNS Deployment Guide addresses email security and recommends properly configured SPF records. A syntactically invalid SPF record — whether due to misplaced directives, lookup limit violations, or deprecated mechanisms — fails to meet NIST email authentication guidelines even though the record technically exists. DNS Spy validates the full structure to ensure true compliance.

What Causes a Failure

This check reports errors that cause a failure, and warnings that are informational. Any error triggers a fail result.

Errors

  • "all" mechanism not in terminal position — Any terms after "all" (including -all, ~all, +all, ?all) are silently ignored by all receiving mail servers per RFC 7208. This is the most dangerous SPF syntax error because the record looks valid but mechanisms are not being evaluated.

  • Exceeding 10 DNS lookup limit — RFC 7208 §4.6.4 limits SPF evaluation to 10 DNS-querying mechanisms (include, a, mx, ptr, exists, redirect). Exceeding this causes a PermError, which means SPF evaluation fails entirely for all incoming email.

  • Missing "all" mechanism — Without an "all" mechanism (and no redirect= modifier), the SPF record defaults to an implicit "?all" (neutral), which provides no sender policy and effectively leaves email unauthenticated.

  • Invalid or unrecognized mechanisms — Typos like "inclde:" instead of "include:" or unknown directives cause SPF evaluation errors. Receiving servers may treat the entire record as invalid.

  • Empty mechanism arguments — Mechanisms like "include:" and modifiers like "redirect=" require a domain argument. An empty argument is invalid and will cause evaluation failures.

  • Deprecated "ptr" mechanism — RFC 7208 §5.5 explicitly states "do not use" for the ptr mechanism. It is slow, unreliable, places unnecessary load on DNS infrastructure, and may not be supported by all receiving mail servers.

  • Invalid macro syntax — Malformed %{...} macro expressions in mechanisms like "exists:" will cause SPF evaluation errors. Valid macro letters are: s, l, o, d, i, p, h, c, r, t, v.

  • Invalid IP addresses or CIDR notation — Malformed IPv4/IPv6 addresses or out-of-range CIDR prefixes in ip4: or ip6: mechanisms will fail to match any connecting IP, silently leaving traffic unauthenticated.

Warnings

  • Using ~all (softfail) instead of -all (hardfail) — Softfail marks unauthorized email as suspicious but does not instruct receivers to reject it. While acceptable in some configurations, hardfail (-all) provides stronger protection against spoofing.

  • Approaching the 10 DNS lookup limit — When your SPF record uses 8 or more DNS lookups, adding another service could push you over the limit and break SPF entirely. Consider consolidating mechanisms or using SPF flattening.

  • Redundant include domains — Including the same domain more than once wastes DNS lookups against the 10-lookup limit without providing any additional authorization.

Good vs. Bad Configuration

Bad Configuration

"v=spf1 include:spf.protection.outlook.com -all exists:%{i}._spf.inkyphishfence.com" — The -all mechanism appears before the exists: mechanism. Everything after -all is silently ignored, so the Inky phishing protection service is never authorized.

Good Configuration

"v=spf1 include:spf.protection.outlook.com exists:%{i}._spf.inkyphishfence.com -all" — All mechanisms are evaluated before the terminal -all, ensuring both Outlook and Inky are properly authorized.

How DNS Spy Monitors This

DNS Spy parses your SPF record during each monitoring cycle and evaluates every term against RFC 7208 requirements. It checks mechanism ordering, counts DNS lookups, validates IP addresses and macro syntax, and identifies deprecated directives. If any structural errors are found, an alert is triggered. Warnings are reported in the check details to help you optimize your SPF configuration before issues arise.

Related

Check This on Your Own Domain

DNS Spy's free scan reads your live DNS, nameservers, SSL and email-authentication records and reports what it finds. No account required. Scan a domain →

If you want the same checks to keep running: DNS Spy re-resolves every monitored domain at least every ten minutes and alerts you when a record changes. See how monitoring works →