Understand the structure of an SPF record
Sender Policy Framework (SPF) describes which servers are allowed to send mail for a domain. The policy lives in a TXT record beginning with v=spf1 followed by mechanisms and modifiers. This page explains what the validator inspects and how to interpret the API response.
Anatomy of an SPF policy
An SPF rule is a list of space separated terms. Each term may start with a qualifier (+, -, ~, ?), followed by a mechanism name (such as ip4, mx, include) or a modifier (redirect=, exp=).
v=spf1 ip4:203.0.113.0/24 include:_spf.example.net -all
Mandatory elements
v=spf1— the version tag must be present and placed at the beginning of the record.- Mechanisms — at least one mechanism (for example
ip4,ip6,mx,include) defines the authorised senders. - Terminal directive — a final mechanism (
-all,~all,?allor+all) completes the policy and tells recipients how to handle unmatched mail.
Optional modifiers
include:chains another SPF record and triggers extra DNS lookups.redirect=delegates the evaluation to a different domain. It must be the last term and cannot appear withall.exp=points to a TXT record containing an explanation message. It is deprecated and only informational.
Frequent pitfalls detected by the tool
- Record too long. SPF strings longer than 450 characters are rejected by the validator.
- Unknown or duplicated terms. Misspelled mechanisms and repeated modifiers are flagged as errors.
- Invalid IP prefixes or domains. The validator checks the syntax of CIDR ranges and hostnames.
- Lookup limits exceeded. SPF processing stops after 10 DNS lookups, including
include,mx,a,ptrandexists. - Neutral or permissive policies. Qualifier
?and+allreduce the protection level and appear as warnings.
Best practices before publishing
- Keep the policy concise and remove unused mechanisms to stay below lookup limits.
- Prefer
ip4andip6ranges managed by your organisation or service provider. - Document who maintains each include chain and review the delegated domains regularly.
- Test the final record with this validator, then query DNS once deployed to confirm propagation.
By validating the syntax ahead of publication you reduce the risk of a broken SPF policy and avoid lengthy troubleshooting when messages start to bounce.