Blog article
SPF record structure overview:
include, a, mx, and exists mechanism~all vs. -all matters most before DMARC reaches enforcementA single misplaced SPF qualifier can break your record.
SPF syntax looks approachable. A TXT record, a handful of mechanisms, and an SPF qualifier. But the structural decisions made when creating an SPF record have consequences that extend well beyond initial configuration. Your DNS lookup count, DMARC alignment, and the auditability of your SPF record all depend on its structure.
This guide is written for email admins, CISOs, and MSP operators. It focuses on the design and operational reasoning behind SPF record structure choices – the decisions that determine whether that structure holds up at scale.
Sendmarc’s DMARC Management Platform gives you visibility into your SPF record structure and sending sources, so configuration decisions get made with full context instead of guesswork.
Most SPF guides stop at syntax and skip the structural decisions that determine whether a record holds up at scale. Get the mechanisms right, publish the record, move on. That approach works for a single domain with two or three sending sources. It fails in every other scenario.
Enterprise environments typically run multiple sending systems: a primary server, a CRM, a marketing platform, a transactional service, and a finance system. Add regional infrastructure, and the SPF record structure decisions become a problem.
The SPF record structure determines:
include chains are auditableThese are SPF architecture decisions. Treating them as syntax is where the operational risk begins.
RFC 7208 caps SPF evaluation at 10 DNS lookups. That limit includes every include, a, mx, and exists mechanism in the chain.
For a lean, single-platform setup, the DNS lookup limit is generous. For an enterprise with five or six SaaS senders, each carrying its own include chain, it’s easy to exceed.
Suppose you configure an SPF record for a mid-size organization:
| Host | Type | Value |
|---|---|---|
@ | TXT | v=spf1 include:_spf.google.com include:sendgrid.net include:spf.protection.outlook.com include:servers.mcsv.net include:_spf.salesforce.com include:spf.mandrillapp.com ~all |
This looks reasonable. Six include references, all legitimate senders. But each include points to a record that itself contains one or more lookups. By the time an evaluating server resolves this chain, you’ll have likely exceeded the DNS lookup limit, which means SPF returns a PermError.
The fix is not to remove senders. The fix is to restructure the SPF record structure to control lookup depth.
Replace include references with the resolved IP ranges:
| Host | Type | Value |
|---|---|---|
@ | TXT | v=spf1 ip4:74.125.0.0/16 ip4:209.85.128.0/17 ip4:149.72.0.0/16 ip4:167.89.0.0/16 ~all |
ip4 and ip6 mechanisms don’t count toward the DNS lookup limit, so SPF flattening eliminates lookup depth entirely.
This SPF record structure choice carries a trade-off: when a provider rotates or expands its IP range, which Google, Salesforce, and major ESPs do, your flattened record becomes inaccurate. SPF authentication may fail for legitimate emails until you update the record manually.
MSPs and businesses managing multiple domains from shared infrastructure can use macros to construct SPF records dynamically. The %{d} macro resolves to the sending domain.
-all vs. ~all SPF Qualifier DecisionThe SPF qualifier at the end of an SPF record determines what happens when a source isn’t listed. -all returns a fail; ~all returns a softfail. Neither SPF qualifier is universally correct.
For companies that have a DMARC policy of p=reject or p=quarantine, the effect of the ~all vs. -all SPF qualifier is minimal. DMARC policy takes precedence.
For environments still building their sender inventory, ~all is the appropriate starting SPF qualifier. It avoids blocking messages from senders not yet identified, while DMARC reporting surfaces those sources for remediation. Once the sender inventory is complete and DMARC is at enforcement, tightening to -all is the operationally sound choice.
include reference more than once wastes lookup budget and signals poor record hygiene during audits.all qualifier: A record without a trailing all SPF qualifier defaults to neutral, which is functionally equivalent to no SPF policy.Managing SPF record structure across multiple domains and sending vendors is an ongoing operational task. Distributed environments make it difficult to see every sending source in one place, and stretched security and IT teams don’t have the capacity to trace lookup chains.
Sendmarc provides continuous visibility into your SPF record, surfacing unknown or unauthorized senders appearing in DMARC aggregate data before they become a compliance or deliverability problem.
Sendmarc’s DMARC Management extends this visibility beyond SPF into DKIM and DMARC authentication, with continuous monitoring and centralized reporting across every domain you manage.