Skip to content
  • There are no suggestions because the search field is empty.

What is SPF and how it works

SPF (Sender Policy Framework) is a DNS TXT record that lists which servers may use your domain as the envelope sender of a message, the bounce address you'll also see called Return-Path. When mail arrives, the receiving server compares the connecting IP address with that list and gets a result such as pass, fail, or softfail. SPF doesn't look at the From address your recipients see, and a pass doesn't mean the message is safe or will reach the inbox. DMARC only counts an SPF pass when the envelope domain is aligned with the visible From domain.

For a short definition of the term, see What is SPF on our main site. This article covers the mechanics: which identity SPF checks, how a check runs, what each result means, and how SPF feeds DMARC.

Which address SPF actually checks

Every message has two senders. The envelope sender (SMTP MAIL FROM) is what servers exchange in transit and where bounces go. The Header From is the address in the mail client. SPF checks the first one. SPF lets a domain owner say which hosts may use the domain in the MAIL FROM identity and, optionally, in the HELO/EHLO name the server introduces itself with.

That difference trips people up. Say you send a newsletter from news@example.com through a marketing platform:

MAIL FROM:<bounces@mail.vendor.example>
From: "Example Co" <news@example.com>

The receiver checks SPF for mail.vendor.example, not example.com. Your own SPF record isn't consulted at all for that message. The full picture of the two addresses is in Envelope From vs Header From.

When the envelope sender is empty, as it is on bounce messages (MAIL FROM:<>), SPF checks postmaster@ the HELO domain instead.

Where the record lives

An SPF record is one DNS TXT record at the domain being checked, and its value starts with exactly v=spf1:

example.com.  TXT  "v=spf1 ip4:192.0.2.10 include:_spf.google.com ~all"

A few rules are fixed:

  • One record per name. Two v=spf1 records at the same name make SPF return a permanent error (Multiple SPF records (why that is invalid)).
  • TXT only. The old dedicated "SPF" DNS record type is discontinued.
  • No inheritance. mail.example.com doesn't use the record at example.com. Every name that appears in MAIL FROM or HELO needs its own record.

How to build one is in How to write an SPF record, and what each term does is in SPF mechanisms: include, a, mx, ip4, ip6, redirect.

How a receiver runs the check

Simplified, a receiving server does this:

  1. Takes the domain from MAIL FROM (or from HELO when MAIL FROM is empty).
  2. Looks up the TXT records at that domain and keeps the one that starts with v=spf1.
  3. Reads the terms left to right and compares each with the connecting IP. The first term that matches decides the result. Its qualifier (+, -, ~, or ?) sets that result.
  4. If nothing matches and there's no redirect, the result is neutral.

Using the record above, suppose mail for example.com arrives from 198.51.100.7:

  • ip4:192.0.2.10 doesn't match.
  • include:_spf.google.com runs a separate check against Google's record. That IP isn't in it, so there's no match.
  • ~all matches everything left, so the result is softfail.

If the mail had come from 192.0.2.10, the first term would have matched with the default + qualifier, and the result would be pass.

Each include, a, mx, ptr, exists, and redirect costs a DNS lookup, and a check may use at most 10 of them, nested ones included. Going over gives a permanent error (The 10-lookup limit and SPF permerror).

The seven SPF results

Result What it means
none No SPF record was found, or there was no usable domain to check.
neutral The domain owner is not asserting whether this IP is authorized.
pass The IP is authorized to use the domain.
fail The domain owner says this IP is not authorized.
softfail A weak statement: the IP is probably not authorized.
temperror A transient problem, usually DNS. A retry may work.
permerror The record can't be interpreted. Someone has to fix DNS.

fail comes from a -all ending and softfail from ~all. The difference, and which ending we recommend, is in Softfail vs fail (~all vs -all).

What receivers do with the result

The result is a statement from the domain owner. What happens to the message is the receiving system's own policy. The SPF result itself doesn't dictate how the message is handled, so one receiver may reject on fail, another may deliver and mark the message, and a third may use SPF as one signal among many.

Mailbox providers have their own rules on top. Gmail, for example, requires all senders to use SPF or DKIM, and bulk senders to use both. The summary for Google, Yahoo, and Microsoft is in Google, Yahoo, and Microsoft sender requirements.

How SPF feeds DMARC

DMARC is where SPF connects to the visible From. DMARC uses only the SPF result for the MAIL FROM domain, never the HELO result, and only when two things are true:

  • SPF returned pass, and
  • the MAIL FROM domain is aligned with the Header From domain. With relaxed alignment, bounce.example.com aligns with example.com because they share an organizational domain.

There is no alignment without an SPF pass. So softfail, fail, neutral, and permerror all count as no SPF pass for DMARC, whatever the ending of your record.

In the newsletter example, SPF passes for mail.vendor.example. That domain isn't aligned with example.com, so the SPF pass doesn't help DMARC. The message needs aligned DKIM, or the platform needs a custom bounce domain under example.com. Using both SPF and DKIM is the recommended setup. More on alignment in Identifier alignment for SPF and DKIM, on DKIM in What is DKIM and how it works, and on DMARC in What is DMARC and how it works. For how the three fit together, see What is email authentication?.

What SPF can't do

  • It doesn't protect the From address people see. SPF says nothing about the From: header. Stopping misuse of the visible From is DMARC's job.
  • It authorizes servers, not people. If you authorize a shared sending platform, anyone who can send through that same infrastructure may pass SPF for your domain.
  • It often breaks on forwarding. A forwarder sends from its own IP, which isn't in your record. Even a correctly set up record can fail on forwarded messages. Aligned DKIM is the more resilient path (Email forwarding, SRS, and ARC).
  • A pass isn't a verdict on the content. Spammers publish SPF records too. SPF tells a receiver who is allowed to send, not whether the mail is wanted.

Misconceptions worth clearing up

  • "I published SPF, so my vendor's mail is covered." Only if the vendor uses your domain (or a subdomain of it) in MAIL FROM. Many platforms use their own bounce domain by default, so SPF passes for them and doesn't align with you.
  • "Subdomains are covered by the main record." They aren't. Each sending name needs its own record.
  • "Domains that don't send mail don't need SPF." They do. Publish v=spf1 -all on them, so receivers can tell that any mail using the domain is unauthorized.

Other common slips are collected in Common SPF mistakes.

Where you'll see SPF results

In a delivered message, the receiver's Authentication-Results header shows the verdict and the domain it checked, for example spf=softfail smtp.mailfrom=example.com. Across all your mail, DMARC aggregate reports list the SPF result and the checked domain for each sending source. Our DMARC reporting and visual analysis shows those results per source, which is a practical way to spot a sender that's missing from your record. A field-by-field guide to the report is in A field-by-field walk-through of a DMARC aggregate report.

Free DMARC account

Turn raw DMARC reports into a readable dashboard

Point your rua address to our platform and read the results by sender and source instead of opening XML files.

  • Results grouped by sending source
  • SPF, DKIM and alignment results per sender
  • The original XML reports are still there to download

Create a free DMARC accountTalk to an expert

FAQ

Does SPF check the From address I see?

No. It checks the envelope sender (Return-Path) domain. DMARC links that domain to the visible From through alignment.

If SPF passes, will my email land in the inbox?

Not necessarily. SPF is one signal, and each receiver decides how to handle mail. If your SPF record is valid and mail still goes to spam, the cause is often something other than SPF.

Does SPF work after forwarding?

Often not, because the forwarder's IP is the one checked. Aligned DKIM is more likely to survive forwarding.

What's the difference between SPF pass and SPF alignment?

Pass means the connecting IP is authorized for the MAIL FROM domain. Alignment means that domain also matches the Header From domain closely enough for DMARC. You need both for SPF to count toward DMARC.

Do I need SPF on domains that never send email?

Yes. v=spf1 -all tells receivers no server is authorized to use the domain.