RFC 7208 SPF: Identity, Evaluation, DNS Limits and Results

· Published · 11 min read

SPF RFC 7208 evaluation path from SMTP MAIL FROM or HELO identity through DNS TXT lookup, bounded mechanisms and receiver result

RFC 7208 defines SPF as authorization of an SMTP client IP to use an RFC 5321 MAIL FROM or HELO domain. It does not authenticate the visible From header, score sender reputation or certify inbox placement. A correct implementation must select one TXT policy, evaluate mechanisms from left to right, enforce global DNS-processing limits and preserve all seven possible results.

What RFC 7208 standardized

Published in April 2014, RFC 7208 obsoleted RFC 4408 and made SPF version 1 a Standards Track protocol. It removed the abandoned requirement to publish and query DNS RR type 99 for SPF, leaving DNS TXT as the required publication format. It also added a recommended void-lookup limit, strongly discouraged the ptr mechanism and %{p} macro, clarified record selection and expanded operational guidance.

The standard defines semantically equivalent behavior through the symbolic check_host() function. A receiver supplies the connecting client IP, the domain being evaluated and the sender identity. An implementation can use different internal code, but it must produce the same protocol result for the same reliable inputs.

Select the correct SMTP identity before checking DNS

SPF normally evaluates the domain in the RFC 5321 reverse path supplied by the SMTP MAIL FROM command. For a null reverse path, as commonly used for delivery-status notifications, the receiver evaluates the HELO or EHLO identity instead. SPF does not directly evaluate the RFC 5322 visible From address shown by a mail client.

This distinction explains a frequent diagnostic error. A message can show spf=pass for a vendor bounce domain while DMARC fails because that authenticated domain does not align with the visible From domain. Conversely, aligned DKIM can allow DMARC to pass even when forwarding breaks SPF. Always retain the evaluated identity beside the result.

Worked identity and evaluation trace

SMTP client IP: 192.0.2.25
MAIL FROM: [email protected]
HELO: mta1.sender.example

1. Identity selected: RFC5321.MailFrom domain example.com
2. TXT selected: "v=spf1 ip4:192.0.2.0/24 include:_spf.vendor.example -all"
3. ip4:192.0.2.0/24 matches the client
4. Qualifier defaults to "+"
5. Evaluation stops with SPF pass
6. DMARC separately compares example.com with the visible From domain

TXT publication and record-selection rules

An SPF policy is published as one DNS TXT resource record whose selected value begins exactly with v=spf1, followed by a space or the end of the record. Other TXT records at the same owner name are ignored unless they also match that version marker. If no matching record exists, the result is none. If more than one matching SPF record exists, the result is permerror.

Multiple quoted character strings inside one TXT resource record are valid and are concatenated without added spaces. They are not multiple SPF records. This is different from publishing two separate TXT RRs that both begin with v=spf1, which is invalid. The RFC recommends keeping the DNS response small enough for reliable transport and gives a practical guideline of keeping the DNS name plus relevant record text under approximately 450 octets.

Mechanisms and modifiers with their real DNS cost

TermWhat it evaluatesDNS-budget effectImportant behavior
allMatches every client.No evaluation-time DNS query.Usually terminates a policy. Its qualifier determines pass, fail, softfail or neutral.
ip4, ip6Compares the client IP with an address or CIDR range.No DNS query.Use the correct address family. A missing qualifier means pass.
aResolves A or AAAA for the target name and compares the client IP.Counts toward the global ten-term limit.The address family follows the connecting client IP.
mxResolves MX targets, then their A or AAAA records.The term and MX processing are subject to Section 4.6.4 limits; each MX record may lead to no more than ten address records.Exceeding the MX address limit produces permerror. It does not mean "authorize whatever receives mail" without bounded DNS work.
includeRecursively evaluates another domain policy.Counts toward the same global ten-term limit, including nested evaluation.The mechanism matches only when the included evaluation returns pass. It is not a text include.
existsExpands a domain specification and tests whether it has any A result.Counts toward the global ten-term limit.It can use macros, so review privacy, query volume and generated-label validity.
ptrPerforms reverse and forward-confirming DNS work.The term and returned PTR processing are bounded by Section 4.6.4, including the ten-address limit.RFC 7208 says do not use it and recommends more reliable alternatives.
redirect=Evaluates another policy only after all mechanisms in the current record fail to match.Counts toward the same global ten-term limit.It is a modifier, not a mechanism. A record can have only one effective redirect modifier.
exp=Retrieves optional explanation text after an SPF fail result.Not part of the ten-term evaluation limit; lookup occurs later.Never trust external explanation text as safe HTML or a policy result.

Evaluation proceeds from left to right. The first mechanism that matches ends processing and returns the result represented by its qualifier: + pass, - fail, ~ softfail or ? neutral. An omitted qualifier means pass. If no mechanism matches and no redirect exists, the result is neutral, as if ?all had been written.

include and redirect are not interchangeable. An include is a mechanism in the ordered list and matches only when the referenced policy passes. Redirect is consulted only after the current record has no matching mechanism and replaces the policy result with evaluation of another domain.

The ten-term limit is global and recursive

RFC 7208 requires a maximum of ten DNS-query-causing terms reached during one SPF evaluation. The counted terms are include, a, mx, ptr, exists and redirect. The budget is global across recursive evaluations, not reset for every included domain. Exceeding it produces permerror.

The number ten is not a limit on TXT strings, outbound IP addresses or only the include statements written in the top-level record. Section 4.6.4 also says MX and PTR processing contributes returned-record queries to the overall boundary and imposes additional address-query limits. An analyzer therefore must model the complete reachable evaluation, not merely count visible top-level tokens. SPF implementations should also limit void lookups to two by default; exceeding that configured limit produces permerror.

Recursive lookup-budget example

example.com      v=spf1 include:a.example include:b.example redirect=c.example
a.example        v=spf1 a include:d.example -all
b.example        v=spf1 mx -all
d.example        v=spf1 exists:%{i}.audit.example -all
c.example        v=spf1 ip4:192.0.2.0/24 -all

Count terms actually reached, including recursive include and redirect paths.
Do not count ip4, ip6, all, or exp as evaluation-time DNS terms.
For mx and ptr, also apply the returned-record and address-query limits
specified in RFC 7208 Section 4.6.4. Stop with permerror when a required
processing limit says the evaluation cannot continue.

Every SPF result has a different meaning

ResultProtocol meaningOperational interpretation
noneNo usable SPF policy was selected for the evaluated identity.Not pass and not fail. It can result from no record, NXDOMAIN or malformed initial domain input.
neutralThe policy makes no assertion for this client.Equivalent to an explicitly matched ?all; local receiver policy decides disposition.
passThe client IP is authorized to use the evaluated MAIL FROM or HELO identity.It does not authenticate the visible From header and does not guarantee DMARC pass or inbox placement.
failThe publisher explicitly says the client is not authorized for the identity.A receiver can reject during SMTP or use the result with other signals.
softfailThe publisher expresses a weak negative assertion.It is not a testing mode defined to expire automatically. Treat it according to local receiver policy.
temperrorA transient failure prevented evaluation, such as DNS timeout or server failure.Retry or defer may be appropriate. Do not report it as fail or none.
permerrorThe policy cannot be evaluated correctly, such as duplicate SPF records, invalid syntax or exceeded limits.Fix the policy. A receiver cannot infer authorization from an invalid record.

Reducing these results to a green or red badge destroys useful evidence. In particular, temperror says the evaluation could not finish because of a probably transient condition, while permerror says the published policy or its processing boundary is invalid. Neither is equivalent to an explicit publisher fail.

How DMARC later consumes SPF results

DKIM was already standardized before RFC 7208: RFC 4871 was published in 2007 and its revision, RFC 6376, was published in 2011. RFC 7208 was published in April 2014 and defines only SPF identity authorization and evaluation. It does not define DKIM authentication or DMARC identifier alignment.

DMARC was first published as RFC 7489 in March 2015, after RFC 7208. DMARC introduced the policy relationship between the visible RFC 5322 From domain and authenticated identifiers. The current DMARC core specification is RFC 9989. Under DMARC, SPF alignment compares the authenticated RFC 5321 MailFrom domain with RFC 5322 From, while DKIM alignment compares a passing signature’s d= domain with RFC 5322 From.

SPF therefore answers whether an IP is authorized for the evaluated SMTP identity. DMARC separately asks whether that authenticated SPF identity, or a passing DKIM identity, aligns with the visible From domain. Relaxed alignment compares organizational domains; strict alignment requires exact domain matching. These are separate protocol stages and must be reported separately.

For example, bounce.vendor.example can pass SPF while a visible From of brand.example fails SPF alignment. A DKIM signature using an aligned d=brand.example could still satisfy DMARC. Report SPF authentication, SPF alignment, DKIM authentication and DKIM alignment as distinct fields.

Record trusted receiver evidence, not sender-supplied claims

RFC 7208 defines the Received-SPF header and also permits SPF results to be represented in Authentication-Results. These headers are useful only inside a defined trust boundary. Internet senders can insert forged copies, so a receiving boundary must remove or ignore untrusted claims before adding its own result.

A useful evidence record contains the result, evaluated identity, connecting IP, receiver or authserv-id, timestamp and source header position. A parser that extracts only the first text token reading spf=pass can mistake an attacker-supplied header for a receiver result.

Production SPF audit procedure

  1. Inventory every SMTP source. Include ESPs, application MTAs, help desks, CRM systems, ticketing systems, forwarding services and IPv6 paths.
  2. Record the exact MAIL FROM domain. The visible From domain alone is insufficient for SPF design.
  3. Retrieve the complete TXT answer. Distinguish one multi-string RR from duplicate v=spf1 RRs.
  4. Expand only the path the evaluator can reach. Count recursive terms and preserve DNS status, CNAME behavior, TTL and void answers.
  5. Test representative IPv4 and IPv6 clients. Confirm the expected result and the identity used.
  6. Verify DMARC alignment separately. Do not label SPF pass as aligned without comparing the authenticated domain with the visible From domain.
  7. Stage changes with TTL awareness. Keep old and new legitimate sources authorized during the transition and remove obsolete authorization after evidence is complete.
  8. Monitor receiver headers and SMTP responses. A syntactically valid record can still omit a production source or exceed limits through a vendor change.

DNS evidence commands

# Retrieve the complete TXT answer set. One TXT RR can contain many strings.
dig +noall +answer TXT example.com

# Trace every include and redirect with its own TTL and status.
dig +noall +answer TXT _spf.provider.example

# Verify the actual outbound IPv4 and IPv6 values independently.
dig +short A outbound.example.net
dig +short AAAA outbound.example.net

# Inspect the receiving MX path only when an mx mechanism is intentional.
dig +noall +answer MX example.com

Why blind SPF flattening is not a complete fix

Replacing includes with current IP literals can reduce runtime DNS terms, but it also copies a provider-controlled authorization set into a static record. If provider addresses change and the flattened record is not refreshed safely, legitimate mail fails. Flattening can also create oversized TXT answers, stale IPv6 coverage and overly broad authorization.

First remove unused senders, consolidate return-path domains and ask providers for bounded SPF architecture. If flattening remains necessary, automate source retrieval, change review, TTL handling, diff approval, validation, rollback and expiry. Never infer that an address discovered through unrelated DNS is authorized for outbound mail.

Failures that a serious analyzer must identify

  • Duplicate selected records: two separate TXT RRs beginning with v=spf1 produce permerror.
  • Wrong identity: checking the visible From domain instead of the SMTP MAIL FROM or HELO domain produces a different question.
  • Recursive budget overflow: nested vendor includes push reached DNS processing beyond the required boundary.
  • Void-query overflow: broken includes or macro-generated names repeatedly return no data or NXDOMAIN.
  • Missing IPv6 authorization: the sender enables IPv6 delivery without an intended ip6 or provider authorization path.
  • Discouraged ptr use: a less reliable mechanism remains in policy even though RFC 7208 recommends alternatives.
  • Untrusted header parsing: a forged Authentication-Results field is reported as receiver evidence.
  • SPF pass called DMARC pass: alignment and the visible author domain were never evaluated.
  • Stale flattening: copied provider addresses no longer represent the provider send pool.

Acceptance criteria for an SPF policy

  • Exactly one selected v=spf1 TXT resource record exists for every active MAIL FROM and HELO domain.
  • Every authorized production IPv4 and IPv6 path produces the intended result.
  • Unauthorized representative clients reach the intended terminal policy.
  • The complete recursive path stays inside required DNS and address limits.
  • No production dependency uses ptr or assumes RR type 99.
  • TXT answer size and DNS transport are reliable from independent resolvers.
  • Received evidence records the evaluated identity, result and trusted receiver boundary.
  • DMARC alignment is evaluated and reported separately.
  • Every vendor authorization has an owner, business purpose and removal procedure.
  • A rollback record and pre-change DNS snapshot are retained.

Current status

RFC 7208 remains the Standards Track specification for SPF version 1. DKIM is a separate authentication protocol, and DMARC was standardized after RFC 7208. Current DMARC processing consumes SPF and DKIM results but does not change which SMTP identity RFC 7208 authenticates. Operators should check the RFC Editor status and verified errata before changing an SPF evaluator.

Primary and normative references

Related technical notes

Technical review

Need this checked against your own sending system?

Share the domain, headers, bounces, provider warning, logs, or infrastructure symptom and NitWings will identify the practical next step.

Schedule a Technical Review
Advertisement