Skip to content

BlogSPF

What is SPF? How an SPF record works (with examples)

SPF is usually the first email authentication record people set up, and the one that breaks most often. Most failures come from three mistakes: too many lookups, two records on one domain, and forwarding. Each one has a fix below, along with examples you can copy for common providers.

Julien Coulaud on X

Founder of Shipmail, the email platform for businesses and their AI agents. Every guide here draws on mail servers running in production.

  • SPF
  • SPF record
  • Email authentication
  • DNS
  • DMARC
  • Deliverability

Short answer

SPF (Sender Policy Framework) is a TXT record in your domain's DNS that lists the servers allowed to send email for that domain. A receiving server looks up the record for the domain in the envelope sender address (the Return-Path, also called MAIL FROM) and checks whether the sending server's IP address is on the list. A simple SPF record looks like v=spf1 include:_spf.google.com ~all. A domain can have only one SPF record, and checking it may take at most 10 DNS lookups.

What SPF is

SPF stands for Sender Policy Framework. You publish one TXT record in your domain's DNS that says which servers may send mail for the domain. When a message arrives, the receiving server compares the IP address that connected to it with that list. If the IP is on the list, SPF passes. If it isn't, the record tells the receiver how strongly to treat that as a failure.[1]

Here is a complete SPF record for a domain that sends all its mail through Microsoft 365: v=spf1 include:spf.protection.outlook.com -all. It reads as: this is SPF version 1, Microsoft 365's servers may send for me, and everything else fails.[5]

What SPF checks, and what it does not

SPF checks the envelope sender, the address the sending server gives in the SMTP MAIL FROM command. It ends up in the Return-Path header of the delivered message, and bounces go to it. Receivers can also check the server name given in HELO, and for a bounce, where MAIL FROM is empty, SPF uses the HELO name instead.Sources[1]RFC 7208: Sender Policy Framework (SPF)[5]Microsoft Learn: set up SPF for your Microsoft 365 domain

SPF does not check the From address you see in your mail app. A message can pass SPF for bounces.mailer.example.net while showing From: ceo@example.com. Tying the result to the visible From address is DMARC's job, covered at the end of this guide.Sources[1]RFC 7208: Sender Policy Framework (SPF)[2]RFC 9989: Domain-based Message Authentication, Reporting, and Conformance (DMARC)

SPF record syntax

An SPF record starts with v=spf1, then lists mechanisms separated by spaces. The receiver reads them left to right and stops at the first one that matches the sending IP address.Sources[1]RFC 7208: Sender Policy Framework (SPF)[5]Microsoft Learn: set up SPF for your Microsoft 365 domain

  • ip4:192.0.2.10 or ip4:192.0.2.0/24 allows one IPv4 address or a range.
  • ip6:2001:db8::10 or ip6:2001:db8::/32 allows one IPv6 address or a range.
  • a allows the IP addresses in the domain's A and AAAA records. a:mail.example.com does the same for another host.
  • mx allows the servers listed in the domain's MX records, the ones that receive its mail.
  • include:_spf.google.com checks another domain's SPF record and passes if that record passes. This is how you allow a provider.
  • all matches everything. It goes last and decides what happens to mail from any server not listed before it.
  • redirect=_spf.example.com is a modifier that hands the whole check to another domain's record. It only applies when nothing else matched, and receivers ignore it if the record has an all.
  • ptr and exists also exist. RFC 7208 says ptr should not be used, and exists is rare outside large senders.
[1]

Each mechanism can start with a qualifier that sets the result when it matches. Without one, the qualifier is +, which means pass. The qualifier matters most on all.[1]

  • -all (fail): mail from anywhere else is not authorized. Microsoft recommends this when DKIM and DMARC are also set up.
  • ~all (softfail): mail from anywhere else is probably not authorized. Receivers usually accept it and may mark it. Google recommends this for Google Workspace.
  • ?all (neutral): the domain makes no statement about other servers. Microsoft calls it a testing value.
  • +all (pass): any server in the world may send as you. Never publish this, because it makes the record useless.
Sources[1]RFC 7208: Sender Policy Framework (SPF)[5]Microsoft Learn: set up SPF for your Microsoft 365 domain[4]Google Workspace Admin Help: set up SPF

SPF record examples

Each example is the value of one TXT record on the root of example.com (often entered as @ in a DNS panel). Replace the provider part with your own, and keep a single record per domain.[1]

  • Google Workspace only: v=spf1 include:_spf.google.com ~all
  • Microsoft 365 only: v=spf1 include:spf.protection.outlook.com -all
  • Zoho Mail only: v=spf1 include:zohomail.com -all
  • Shipmail only: v=spf1 include:spf.shipmail.to -all
  • Two services at once, for example while moving from Google Workspace to Microsoft 365: v=spf1 include:_spf.google.com include:spf.protection.outlook.com -all
  • Microsoft 365 plus your own server at a fixed IP address: v=spf1 ip4:192.0.2.10 include:spf.protection.outlook.com -all
  • A domain whose own MX servers send its mail: v=spf1 mx -all
  • A domain that sends no mail at all, such as a parked domain: v=spf1 -all
  • Several domains sharing one policy: v=spf1 redirect=_spf.example.com on each domain, with the real list published at _spf.example.com
Sources[4]Google Workspace Admin Help: set up SPF[5]Microsoft Learn: set up SPF for your Microsoft 365 domain[6]Zoho Mail: SPF configuration[8]Shipmail domain setup documentation[1]RFC 7208: Sender Policy Framework (SPF)

Only one SPF record per domain

A domain must not publish two TXT records that start with v=spf1. If it does, receivers cannot tell which one to use and SPF returns permerror for every message. This often happens when a new service's setup guide says to add its SPF record and the old one stays in place.Sources[1]RFC 7208: Sender Policy Framework (SPF)[5]Microsoft Learn: set up SPF for your Microsoft 365 domain

The fix is to merge them. Take v=spf1 include:_spf.google.com ~all and v=spf1 include:zohomail.com -all, keep one v=spf1 at the start and one all at the end, and put both includes in between. Subdomains are separate: news.example.com needs its own record if it sends mail, because the record on example.com does not cover it.Sources[1]RFC 7208: Sender Policy Framework (SPF)[5]Microsoft Learn: set up SPF for your Microsoft 365 domain[6]Zoho Mail: SPF configuration[4]Google Workspace Admin Help: set up SPF

The 10 DNS lookup limit (permerror: too many DNS lookups)

Checking an SPF record may take at most 10 DNS lookups. The include, a, mx, ptr and exists mechanisms and the redirect modifier each cost one, and so do the ones inside every record an include points to. ip4, ip6 and all cost nothing. Go over 10 and the result is permerror, which receivers treat as a failure. Some send a bounce saying the message required too many lookups.Sources[1]RFC 7208: Sender Policy Framework (SPF)[5]Microsoft Learn: set up SPF for your Microsoft 365 domain

Count nested lookups too. An include whose record contains three more includes costs four lookups, so five includes in your own record can already be more than 10.[5]

There is a second, smaller limit: void lookups, where a name in the record returns no answer or does not exist. Receivers should allow no more than two. An include for a service you stopped using, whose domain is gone, can use up that allowance.[1]

How to fix too many lookups

To fix an SPF record that goes over 10 DNS lookups, remove includes you no longer use, move bulk senders to a subdomain, and flatten only vendors with fixed IP ranges.[5]

  1. Step 1

    Remove what you no longer use

    Delete includes for services that no longer send as your domain, and replace a or mx with ip4 when you know the addresses.

  2. Step 2

    Move bulk senders to a subdomain

    Send newsletters from news.example.com with its own SPF record. Each domain and subdomain gets its own budget of 10 lookups.

  3. Step 3

    Flatten only stable senders

    Flattening replaces an include with the IP addresses it resolves to. Do it only for a vendor that documents fixed IP ranges, and check those ranges regularly. Microsoft says not to flatten Microsoft 365, because its addresses change often.

[5]

Shipmail's free SPF checker resolves every include in your record and shows the lookup count against the limit of 10.

SPF results: pass, fail, softfail and the rest

An SPF check returns one of seven results: pass, fail, softfail, neutral, none, permerror or temperror. Only pass means the sending server is allowed to send for the domain.[1]

  • pass: the sending server is allowed.
  • fail: the sending server is not allowed. The record ended in -all.
  • softfail: the server is probably not allowed. The record ended in ~all.
  • neutral: the domain makes no statement, as with ?all.
  • none: the domain has no SPF record, or no domain could be checked.
  • permerror: the record cannot be read. Two SPF records, too many lookups, or a syntax error cause this, and only the domain owner can fix it.
  • temperror: a temporary DNS error. A later retry may succeed.
[1]

You can see the result in the Authentication-Results header of any message you receive, written as spf=pass or spf=softfail.[3]

Why SPF breaks when mail is forwarded

SPF checks the IP address of the last server that handed over the message. When someone forwards their address to another inbox, the forwarding server resends your message from its own IP address while keeping your domain as the envelope sender. That IP is not in your record, so SPF fails, even though you sent the message correctly.Sources[1]RFC 7208: Sender Policy Framework (SPF)[2]RFC 9989: Domain-based Message Authentication, Reporting, and Conformance (DMARC)

Some forwarders avoid this by rewriting the envelope sender to their own domain. You can't control that, so SPF should never be your only check. DKIM signatures usually survive forwarding, so a domain with both SPF and DKIM still passes DMARC when SPF breaks.Sources[1]RFC 7208: Sender Policy Framework (SPF)[2]RFC 9989: Domain-based Message Authentication, Reporting, and Conformance (DMARC)

SPF and DMARC alignment

DMARC uses SPF only when two things are true: SPF passes, and the envelope sender's domain matches the domain in the visible From address. That match is called alignment. By default it is relaxed, so bounce.example.com aligns with example.com because they share the same organizational domain.[2]

Many sending services use their own domain as the envelope sender. Your mail then passes SPF for their domain and still fails DMARC's SPF check for yours. The fix is a custom return path, a subdomain of yours that the service asks you to point at it, or DKIM signing with your domain. Gmail requires SPF or DKIM alignment from anyone sending more than 5,000 messages a day to Gmail accounts.Sources[2]RFC 9989: Domain-based Message Authentication, Reporting, and Conformance (DMARC)[7]Gmail email sender guidelines

SPF on Shipmail

When you add a domain to Shipmail, it gives you the SPF, DKIM, DMARC and MX records and can publish them for you. If your domain already has an SPF record, Shipmail suggests a merged value, such as v=spf1 include:_spf.google.com include:spf.shipmail.to -all during a move from Google. It rechecks the records every 30 seconds until they verify.[8]

Newsletters and transactional email do not add includes to your root record. Each sends from its own subdomain with its own SPF and return-path records, so your root domain stays well under the 10-lookup limit.Sources[9]Shipmail newsletter editor documentation[10]Shipmail transactional email documentation

Sources10 sourcesVerified 2026-11-09
  1. [1]
    RFC 7208: Sender Policy Framework (SPF)

    Sections 1.1.3 and 2.4: SPF checks the MAIL FROM identity from the SMTP envelope, and can also check HELO. Section 2.6: results are none, neutral, pass, fail, softfail, temperror and permerror. Section 3.2: a domain must not publish more than one SPF record; Section 4.5: two records give permerror. Section 4.6.2: the qualifiers + (pass, the default), - (fail), ~ (softfail) and ? (neutral). Section 4.6.4: include, a, mx, ptr, exists and redirect count toward a limit of 10 DNS lookups, all, ip4 and ip6 do not, and void lookups should be limited to two; going over gives permerror. Section 5.5: ptr should not be published. Section 6.1: redirect is ignored when the record has an all mechanism. Section 10.3 and Appendix D: a forwarder resends from its own IP address, so SPF fails unless the forwarder rewrites MAIL FROM.

    rfc-editor.org · 2026-10-11

  2. [2]
    RFC 9989: Domain-based Message Authentication, Reporting, and Conformance (DMARC)

    Published May 2026 on the Standards Track; obsoletes RFC 7489 and RFC 9091. Section 4.7 tags: v=DMARC1 (required, first), p (none, quarantine, reject; treated as none if absent), sp (existing subdomains, defaults to p), np (non-existent subdomains), psd, t (test mode y or n, default n), rua and ruf (mailto: report addresses), adkim and aspf (r relaxed or s strict, default r), fo (default 0, ignored without ruf: 0 asks for a failure report when all mechanisms fail to give an aligned pass, 1 when any fails, d when a DKIM signature failed, s when SPF failed). Section 4.1: the policy record is a TXT record at _dmarc.<domain>. With t=y the domain owner is testing and expects failing mail to get the policy one step lower, so quarantine becomes none and reject becomes quarantine; t has no effect on reports. Relaxed alignment means the same organizational domain, strict means identical domains. If several DMARC records are returned for one name, all are discarded. Appendix A.6 removes pct, replaced by t, whose y and n values match pct=0 and pct=100; Appendix C.5.2 lists rf and ri as removed. Section 7.4: in forwarding, SPF will most likely fail while DKIM signatures generally remain valid; a domain publishing p=reject MUST NOT rely only on SPF and MUST apply valid DKIM signatures; domains whose users post to mailing lists should not publish p=reject, or should first publish p=none for at least a month and then p=quarantine for as long.

    rfc-editor.org · 2026-10-11

  3. [3]
    RFC 8601: Authentication-Results header field

    Authentication-Results records the results of message authentication checks such as SPF and DKIM so mail clients and filters can use them. The receiving server that performed the checks adds it at the top of the message; the first element is the authserv-id naming that service. Before adding its own, a server should remove instances claiming to come from its own trust boundary. Results include pass, fail, softfail (SPF), neutral, none, temperror and permerror.

    rfc-editor.org · 2026-10-11

  4. [4]
    Google Workspace Admin Help: set up SPF

    For a domain that sends only through Google Workspace, the SPF record is v=spf1 include:_spf.google.com ~all. Each domain must have its own SPF record, and Google recommends ~all.

    knowledge.workspace.google.com · 2026-10-11

  5. [5]
    Microsoft Learn: set up SPF for your Microsoft 365 domain

    SPF checks the MAIL FROM (envelope sender) address. For Microsoft 365 the record is v=spf1 include:spf.protection.outlook.com -all, and a parked domain that sends no mail publishes v=spf1 -all. Only one SPF record is allowed per domain or subdomain, and each subdomain needs its own. Microsoft recommends -all with DKIM and DMARC. More than 10 DNS lookups gives permerror; include, a, mx, exists and redirect each count, ip4, ip6 and all do not. To reduce lookups: replace includes with IP addresses for vendors with stable ranges (flattening), move services to subdomains, or consolidate services. Microsoft 365 itself should not be flattened because its IP addresses change.

    learn.microsoft.com · 2026-10-11

  6. [6]
    Zoho Mail: SPF configuration

    The SPF record for Zoho Mail is v=spf1 include:zohomail.com -all. A domain should have only a single SPF record, so other senders are added as extra include values in the same record.

    zoho.com · 2026-10-11

  7. [7]
    Gmail email sender guidelines

    Since February 1, 2024, all senders to Gmail need SPF or DKIM, valid forward and reverse DNS, TLS, RFC 5322 formatting, and a Postmaster Tools spam rate below 0.3% (best practice below 0.1%). Senders of more than 5,000 messages a day also need SPF, DKIM and DMARC (policy may be none), a From domain aligned with SPF or DKIM, and one-click unsubscribe for marketing and subscribed mail. Messages of the same category should have the same From address, display names should be a consistent and accurate statement of the sender's identity, and subject lines should not start with Re: or Fwd: unless the message is a real reply or forward. The page does not mention no-reply addresses.

    support.google.com · 2026-10-11

  8. [8]
    Shipmail domain setup documentation

    Adding a domain to Shipmail: four DNS records (MX, SPF, DKIM and DMARC), published automatically or by hand, suggested merging of an existing SPF record, and verification that rechecks the records every 30 seconds.

    shipmail.to · 2026-10-11

  9. [9]
    Shipmail newsletter editor documentation

    Newsletters written in Shipmail with a rich text editor, design blocks, custom HTML or plain text, preview, test sends and pre-send review checks.

    shipmail.to · 2026-10-15

  10. [10]
    Shipmail transactional email documentation

    Shipmail transactional email: an app sends from its own sending subdomain of a domain already verified in Shipmail, and replies go to a Shipmail mailbox. Sends count toward the plan's monthly quota, a sender costs nothing extra, Activity shows delivery status, and a retry with the same Idempotency-Key returns the first message. Every email from a sender carries its mailbox's address as Reply-To, so replies arrive in that mailbox's Transactional folder; the sending address itself cannot receive email. On a paid plan, an organization's transactional email starts at a safety limit of 1,000 recipients a day, raised daily to twice the highest clean day of the last 7 days, up to 25,000 automatically; the plan keeps 80% of its daily limit as a floor; a migration review with the last 30 days gets an answer within one business day.

    shipmail.to · 2026-11-09

Questions worth answering

Common questions about what is spf.

What is an SPF record?
A TXT record in your domain's DNS that starts with v=spf1 and lists the servers allowed to send email for the domain. Receiving servers check it against the IP address that delivered each message.[1]
Should I use -all or ~all?
Both count as an SPF failure for DMARC. Microsoft recommends -all once DKIM and DMARC are in place, and Google recommends ~all for Google Workspace. Use ~all while you are still finding every service that sends as your domain.Sources[5]Microsoft Learn: set up SPF for your Microsoft 365 domain[4]Google Workspace Admin Help: set up SPF
Can a domain have two SPF records?
No. Two TXT records starting with v=spf1 make SPF return permerror. Merge them into one record with every include between a single v=spf1 and a single all.Sources[1]RFC 7208: Sender Policy Framework (SPF)[5]Microsoft Learn: set up SPF for your Microsoft 365 domain
What does SPF permerror too many DNS lookups mean?
Checking your record took more than 10 DNS lookups, counting includes nested inside other includes. Remove unused includes, move bulk senders to a subdomain, or replace stable includes with IP addresses.Sources[1]RFC 7208: Sender Policy Framework (SPF)[5]Microsoft Learn: set up SPF for your Microsoft 365 domain
What is the SPF record for a domain that sends no email?
v=spf1 -all. It says no server may send mail for the domain, which stops others from using a parked domain in the envelope sender.[5]
Is SPF enough on its own?
No. SPF does not check the visible From address and fails when mail is forwarded. Add DKIM and a DMARC policy so receivers can tie your mail to the From domain.Sources[1]RFC 7208: Sender Policy Framework (SPF)[2]RFC 9989: Domain-based Message Authentication, Reporting, and Conformance (DMARC)[5]Microsoft Learn: set up SPF for your Microsoft 365 domain

Related guides

More on Shipmail pricing, comparisons, and team workflows.

Email, newsletters and booking pages on your own domain, in one plan.

Get started for free