schedule 15-min read

What Is SPF and Why Does It Matter for DMARC?

DMARC AI editorial team · Last updated

What is SPF? How receivers check the envelope sender against your DNS record, what each result means, and why DMARC needs an aligned SPF pass.

01

Introduction

SPF (Sender Policy Framework, RFC 7208) is a DNS TXT record that lists which servers may send mail using your domain in the SMTP envelope. Receivers compare the connecting IP address with that list. DMARC uses SPF as one of its two inputs, but only counts it when the SPF domain aligns with the visible From domain.

This guide explains what SPF checks, how receivers evaluate it, what each result means, and where it stops being useful for DMARC. For the full set of SPF guides, start at the SPF pillar page.

02

Key takeaways

  • SPF authorises IP addresses for the envelope sender (SMTP MAIL FROM, or the HELO name when the envelope is empty), not for the From address people see.
  • A receiver evaluates the record left to right, stops at the first match, and returns one of seven results: pass, fail, softfail, neutral, none, temperror or permerror.
  • Evaluation may trigger at most 10 DNS-querying terms and should allow at most 2 void lookups; going over either returns permerror.
  • DMARC (RFC 9989) only counts an SPF pass whose domain aligns with the RFC 5322 From domain. A pass for a third-party bounce domain does nothing for DMARC.
  • Forwarding breaks SPF by design, so every domain heading for p=reject needs aligned DKIM as well.
03

What does SPF actually check?

SPF checks one question: is the server connecting to me allowed to send mail for the domain it claims in the SMTP envelope? The receiver takes the domain from the MAIL FROM command (also called the Return-Path or bounce address), fetches that domain's SPF record from DNS and tests the connecting IP against it.

Three details matter here:

  1. It is the envelope, not the header. The MAIL FROM address is used for bounces and is usually invisible to the recipient. The address shown in the mail client is the RFC 5322 From: header, and SPF never looks at it.
  2. HELO is checked too. RFC 7208 recommends that verifiers also check the HELO/EHLO hostname separately. When the reverse path is empty (MAIL FROM:<>, used for bounces and delivery reports), SPF evaluates postmaster at the HELO domain instead.
  3. It authorises paths, not messages. SPF says "this IP may send for this envelope domain". It does not sign the message, so it proves nothing about the content and does not survive the message being relayed through another server.

This is why SPF on its own cannot stop someone spoofing your brand in the From header. The longer argument is in why SPF alone is not enough to stop spoofing.

04

What does an SPF record look like?

An SPF record is a single TXT record at the domain it protects, starting with v=spf1 and followed by mechanisms and modifiers. RFC 7208 requires publication as a TXT record only; the old dedicated SPF record type was discontinued. Here is a typical record for a small business domain, annotated:

example.co.uk.  IN TXT  "v=spf1 ip4:198.51.100.10 ip6:2001:db8:10::/48 mx include:_spf.google.com include:sendgrid.net -all"

Term What it does Counts toward the 10-lookup limit?
v=spf1 Version tag. Must be first, exactly as written. No
ip4:198.51.100.10 Authorises one IPv4 address (an on-premises scanner or app server). No
ip6:2001:db8:10::/48 Authorises an IPv6 range. No
mx Authorises the hosts listed in the domain's MX records. Yes (1)
include:_spf.google.com Evaluates Google's record and matches if it passes. Yes (1, plus any nested lookups)
include:sendgrid.net Same for a transactional email service. Yes (1, plus any nested lookups)
-all Everything not matched above returns fail. No

Each term can carry a qualifier: + (pass, the default when none is written), - (fail), ~ (softfail) or ? (neutral). So -all means "fail everything else" and ~all means "softfail everything else". For every mechanism, qualifier and modifier in detail, see the SPF syntax reference. For the exact meaning of Google's own include, see the Google Workspace SPF record explained.

A domain must publish exactly one v=spf1 record. If a lookup returns two, the result is permerror for every message; merging multiple SPF records shows how to combine them safely.

05

How does a receiver evaluate an SPF record?

The receiver runs what RFC 7208 calls check_host(): it fetches the TXT record for the envelope domain, then tests each mechanism from left to right. The first mechanism that matches ends the evaluation, and its qualifier becomes the result. If nothing matches and there is no redirect, the result is neutral, as if ?all had been written.

A worked example using the record above. A message arrives from IP 203.0.113.25 whose envelope sender (MAIL FROM) is an invoices address at example.co.uk:

  1. ip4:198.51.100.10: no match.
  2. ip6:2001:db8:10::/48: not an IPv6 connection, no match.
  3. mx: the receiver resolves the MX hosts of example.co.uk and their addresses. No match.
  4. include:_spf.google.com: the receiver evaluates Google's record. 203.0.113.25 is not in it, so the include does not match.
  5. include:sendgrid.net: no match.
  6. -all: matches everything, so the result is fail.

Practical consequences of this model:

  • Anything after all is ignored. A mechanism placed after -all is never tested, and a redirect modifier is ignored when all is present.
  • The result belongs to the envelope domain. If the envelope domain is a provider's bounce domain, the provider's record is evaluated, not yours. That point drives the DMARC alignment issue below.

You can see which envelope domain and result a receiver actually recorded by pasting a message's headers into the email header analyzer and looking for the Received-SPF or Authentication-Results line.

06

What do the SPF results mean?

RFC 7208 defines seven results. Only pass is a positive statement; the others are either negative, non-committal or errors. Receivers decide what to do with each one locally, and DMARC simplifies them further into "aligned pass" or "not".

Result RFC 7208 meaning Typical cause Effect on DMARC
pass The client is authorised to use the identity. IP matched a + mechanism. Counts only if the domain aligns.
fail The client is explicitly not authorised. Matched -all or another - term. No SPF contribution.
softfail The host is probably not authorised (a weak statement). Matched ~all. No SPF contribution.
neutral The domain owner makes no assertion. Matched ?all, or nothing matched. No SPF contribution.
none No SPF record found, or no valid domain to check. Missing record. No SPF contribution.
temperror A transient error, usually DNS, during the check. DNS timeout or SERVFAIL. No SPF contribution for that attempt.
permerror The published records could not be interpreted. Syntax error, two records, over the lookup limits. No SPF contribution.

The important line is the last column. For DMARC, a softfail and a fail behave the same: neither produces an SPF pass, so the message needs aligned DKIM to pass. Where ~all and -all differ is in how receivers treat the SPF result before or alongside DMARC; RFC 9989 warns that a hard-fail -all can lead some receivers to reject mail early, before DMARC processing takes place. That trade-off is covered in SPF softfail vs hardfail with DMARC.

07

What is the SPF 10-lookup limit, and what are void lookups?

To protect receivers from expensive or abusive records, RFC 7208 caps the number of DNS-querying terms one evaluation may trigger at 10. The terms that count are include, a, mx, ptr, exists and the redirect modifier, including those inside nested includes. Exceeding the cap returns permerror.

The details worth knowing:

  • What does not count. ip4, ip6, all and the exp modifier do not trigger DNS queries during evaluation, so they are free.
  • Nested includes add up. include:_spf.google.com costs one lookup for the include itself plus whatever Google's record includes. A record with five vendor includes can easily pass 10 once the nesting is counted.
  • Per-mechanism address limits. Evaluating a single mx term must not query more than 10 address records, and ptr ignores everything after the first 10 names. RFC 7208 says the ptr mechanism should not be published at all.
  • Void lookups. A void lookup is a DNS query that returns no answer (an empty response or NXDOMAIN). RFC 7208 says implementations should allow no more than two; a third returns permerror. Stale includes pointing at a vendor you stopped using years ago are the classic cause.
  • Record size. Each TXT string is limited to 255 characters (longer records are split into several quoted strings), and RFC 7208 suggests keeping the whole answer under about 450 octets so it fits in a UDP response.

A permerror is silent: mail still flows, but every message loses its SPF pass, and DMARC then depends entirely on DKIM. If a domain is over the limit, the fix options (removing dead includes, replacing includes with DKIM-only senders, moving senders to subdomains, flattening) are covered in SPF too many DNS lookups and SPF flattening explained for MSPs. The SPF analyzer counts lookups for you, including nested ones.

08

Why is an SPF pass not enough for DMARC?

An SPF pass is not enough because DMARC asks a second question: does the domain that passed SPF match the domain in the visible From header? RFC 9989 calls this alignment. DMARC uses only the SPF result for the MAIL FROM identity (not HELO), and that domain must align with the RFC 5322 From domain.

A common example. A client sends newsletters through an email service provider:

MAIL FROM domain:  mail.esp-example.net   (bounce address at the ESP)
From domain:       example.co.uk          (visible "Example Ltd" newsletter address)
SPF result: pass (for mail.esp-example.net)
DMARC SPF alignment: fail (esp-example.net is not example.co.uk)

SPF passed, but for the provider's bounce domain, so it contributes nothing to DMARC for example.co.uk. Unless the provider signs with an aligned DKIM key (d=example.co.uk), or is configured to use a custom bounce domain such as bounce.example.co.uk, DMARC fails. The full troubleshooting path for this is in why does DMARC fail when SPF passes.

How alignment is judged:

  • Relaxed (default, aspf=r). The two domains must share the same organisational domain, so bounce.example.co.uk aligns with example.co.uk. RFC 9989 notes that nearly all domain owners find relaxed alignment sufficient.
  • Strict (aspf=s). The domains must be identical.
  • Organisational domain discovery. RFC 9989 replaces the old Public Suffix List approach with a "DNS Tree Walk" that looks for DMARC records up the domain hierarchy.

DMARC passes if either SPF or DKIM produces an aligned pass. That is why SPF and DKIM are complementary, not alternatives; how SPF, DKIM and DMARC work together covers the combined flow, and DMARC alignment explained goes deeper on relaxed versus strict. Mailbox providers apply the same logic: Google's email sender guidelines require SPF or DKIM for all senders, SPF and DKIM plus DMARC for bulk senders, and a From domain aligned with either the SPF or the DKIM domain.

09

Why does forwarding break SPF?

Forwarding breaks SPF because the forwarding server re-sends your message from its own IP address while usually keeping your original MAIL FROM. The next receiver checks your SPF record, finds the forwarder's IP is not listed, and returns fail or softfail. SPF cannot describe every server that might relay your mail.

RFC 7208 acknowledges this and describes mitigations in its Appendix D, such as forwarders rewriting the MAIL FROM to their own domain (schemes such as SRS work this way) or receivers trusting known forwarders. Rewriting fixes SPF at the next hop, but the rewritten domain no longer aligns with your From domain, so it does not rescue DMARC either.

RFC 9989 is direct about the consequence: domains publishing p=reject must not rely solely on SPF to secure a DMARC pass, and it notes that DKIM signatures generally remain valid through these relays. In practice:

10

So why does SPF still matter for DMARC?

SPF still matters because it gives DMARC a second, independent route to a pass, and RFC 9989 recommends domain owners use both SPF and DKIM. When a DKIM key is rotated badly, a signature breaks in transit or a vendor signs with its own domain, an aligned SPF pass can carry direct mail through.

SPF also does useful work outside DMARC:

  • Inventory. Writing an accurate SPF record forces you to list every system that sends as the domain, which is the first step of any DMARC project.
  • Receiver requirements. Major mailbox providers expect SPF on sending domains, as the Google guidelines above show.
  • Parked and non-sending domains. A record of v=spf1 -all states clearly that the domain sends no mail.

RFC 9989 also tells domain owners to review their SPF records carefully before publishing DMARC. The order that works is: inventory senders, fix SPF, configure aligned DKIM, publish DMARC at p=none, then move through p=quarantine to p=reject using aggregate reports. The DMARCbis changes behind that rollout are summarised in RFC 9989 explained.

11

What should an MSP check on every client domain?

For an MSP, SPF is a portfolio problem: dozens or hundreds of client domains, each with its own vendors, history and DNS host. The goal is a record per domain that is accurate, inside the limits and backed by aligned DKIM, plus a change process that keeps it that way.

A checklist to run at onboarding and after every sender change:

  1. One record only. Exactly one v=spf1 TXT record at each sending domain and subdomain.
  2. Lookup count under 10, void lookups under 2. Count nested includes, not just top-level terms.
  3. No dead includes. Remove vendors the client no longer uses; these cause void lookups and widen the attack surface.
  4. No ptr, no +all. +all authorises the whole internet; ptr is slow and discouraged by RFC 7208.
  5. A deliberate ending. Choose ~all or -all knowingly, and document why for that client.
  6. Alignment per sender. For each platform in aggregate reports, record whether SPF aligns (custom bounce domain) and whether DKIM aligns. Senders with neither block enforcement.
  7. Aligned DKIM everywhere. Treat SPF as the backup path, never the only one, before any domain goes to p=reject.
  8. Non-sending domains locked down. v=spf1 -all on parked domains, alongside a reject DMARC policy.
  9. Change control. Route every new marketing, CRM or helpdesk tool through a ticket that updates SPF and DKIM before the tool goes live.
  10. Recheck after DNS moves. Registrar or DNS host migrations are a common moment for records to be dropped or duplicated.

Supporting guides: the DMARC onboarding checklist for MSP clients, DMARC client discovery, SPF record best practices and a DMARC change management policy for MSP portfolios.

12

FAQ

Does SPF check the From address that people see?

No. SPF checks the domain in the SMTP MAIL FROM (Return-Path), and the HELO name when the envelope is empty. The visible From header is never examined by SPF itself. DMARC closes that gap by requiring the SPF-passing domain to align with the visible From domain before the SPF pass counts.

Is SPF softfail treated as a pass by DMARC?

No. DMARC only uses an SPF pass whose domain aligns with the From domain. A softfail, neutral, none or permerror gives no SPF contribution, exactly like a fail. The message can still pass DMARC through an aligned DKIM signature, which is why DKIM coverage matters more than the choice of ~all or -all.

What happens when an SPF record exceeds 10 DNS lookups?

The receiver stops evaluating and returns permerror. Mail is not automatically rejected, but no message from that domain gets an SPF pass, so DMARC relies entirely on DKIM. Domains without aligned DKIM on every sender then start failing DMARC, which becomes visible as rejected or junked mail once the policy is enforced.

Do I need SPF if all my senders use aligned DKIM?

Yes, keep it. RFC 9989 recommends using both, and an aligned SPF pass is a fallback when a DKIM signature breaks or a key rotation goes wrong. Google also requires SPF and DKIM for bulk senders. An accurate SPF record costs little to maintain and doubles your routes to a DMARC pass.

Should parked domains have an SPF record?

Yes. Publish v=spf1 -all on any domain that sends no mail, so receivers get an explicit fail for anything claiming it. Pair it with a DMARC record at p=reject. Together they make the domain far less useful for spoofing, and they cost nothing to maintain once published.

13

Next steps

Look up each client domain's SPF record with the SPF analyzer or the DNS lookup tool, confirm there is one record inside the lookup limits, then use aggregate reports to check which senders actually produce an aligned SPF or DKIM pass. Once SPF is accurate and DKIM covers every sender, the domain is ready for DMARC enforcement. For everything else SPF-related, return to the SPF pillar page.

Related articles

Related tools

Ready to Implement?

Get authenticated mail moving in minutes: start free, book a guided demo, or talk to the team about your stack.