Black Friday: 60% off yearly plans with code BF2026, until November 30. See the deal

Learn

SPF record: what it is and how to write one

An SPF record is a single DNS TXT record, starting with v=spf1, that lists the servers allowed to send email for your domain. Receiving servers compare the sending IP against that list and return pass, fail, softfail, neutral or an error.

The short answer
  • One TXT record at the domain apex, beginning with v=spf1 and ending with an all mechanism.
  • A domain may publish only one SPF record. Two records cause a permanent error (permerror).
  • Evaluation stops after 10 DNS-querying terms, so every include has a cost.
Try the spf record checkerFree, live, no signup

Which mechanisms can an SPF record use?

SPF terms from RFC 7208 and whether they cost a DNS lookup
TermMatchesCounts toward 10 lookups
ip4: / ip6:A sending IP or CIDR range you listNo
aThe IP of the domain A or AAAA recordYes
mxThe IPs of the domain MX hostsYes
include:Whatever the named domain SPF record authorizesYes
exists:Any A record returned for a constructed nameYes
redirect=Replaces the record with another domain policyYes
ptrReverse DNS match (RFC 7208 marks it do not use)Yes
allEverything not matched earlierNo

Source: RFC 7208, section 4.6.4 and section 5.5.

What does a working SPF record look like?

TXT record on the root of example.com (host @)
example.com.  3600  IN  TXT  "v=spf1 ip4:192.0.2.0/24 include:_spf.google.com ~all"
; v=spf1                  version tag, must come first
; ip4:192.0.2.0/24        your own mail server range
; include:_spf.google.com  Google Workspace senders
; ~all                    softfail everything else

What do the qualifiers mean?

+ (pass)

The default when no qualifier is written. The sender is authorized.

- (fail)

Written -all. The sender is not authorized and receivers may reject.

~ (softfail)

Written ~all. Probably not authorized. RFC 7208 says receivers should not reject on this alone.

? (neutral)

Written ?all. No statement either way.

How do you add or change an SPF record safely?

  1. 01

    List every sender

    Mail server, Google Workspace or Microsoft 365, newsletter tool, CRM, help desk, invoicing app.

  2. 02

    Look for an existing record

    Query TXT on the apex. If one v=spf1 record exists, edit it instead of adding a second.

  3. 03

    Add one include per service

    Copy the exact include or ip4 value from each vendor documentation.

  4. 04

    End with ~all or -all

    Start with ~all while you confirm nothing legitimate is missing.

  5. 05

    Test and wait

    Run the SPF checker, then send to a test mailbox and read the Authentication-Results header.

Changes are silent

An SPF record that someone edits or deletes breaks mail without any error on your side. DNS monitoring keeps a history of every DNS record change per domain, so an altered TXT record shows up with a date.

Which domains need an SPF record?

  • Every domain and subdomain that appears in the From or return-path address of outgoing mail
  • Subdomains used by newsletter or transactional tools: Google states each subdomain needs its own SPF record
  • Domains that never send mail, which can publish v=spf1 -all as RFC 7505 suggests for non-sending domains
  • The domain a vendor uses as your return path, if the vendor lets you point one at your DNS
  • Parked domains you own, since spoofers pick unprotected names

What goes wrong with SPF records?

Two records

Adding a vendor value as a new TXT record instead of merging it gives permerror under RFC 7208.

Over 10 lookups

Every include, a, mx, exists and redirect counts. Past 10 the result is permerror.

Missing all

With no all and no redirect, unmatched senders get neutral, so nothing is enforced.

Long strings

A single TXT string is limited to 255 octets. Longer records are split into several strings that are joined without spaces.

Common questions

What is an SPF record in simple terms?

It is a public list, stored in DNS as a TXT record, of the servers allowed to send email using your domain. A receiving server looks the list up and compares it with the IP that delivered the message.

Can a domain have two SPF records?

No. RFC 7208 says more than one v=spf1 record on the same name gives a permanent error (permerror), and receivers treat the check as failed. Merge every sender into one record.

Is SPF a TXT or an SPF record type?

A TXT record. RFC 7208 retired the dedicated SPF record type, so publish the policy as TXT only.

Does SPF alone stop spoofing?

No. SPF checks the envelope sender (MAIL FROM), not the visible From address. DMARC adds the alignment check that ties SPF or DKIM to the From domain.

Where do I put my SPF record?

At the DNS zone where your domain nameservers point, as a TXT record on the root (host @). A subdomain that sends mail needs its own TXT record at that subdomain.

What if my SPF record has no all at the end?

If no mechanism matches and there is no redirect, RFC 7208 says the result is neutral, as if ?all were present. The record then authorizes nothing and blocks nothing, so end with ~all or -all.

Watch your domains automatically

Aepto monitors expiry, DNS, SSL and uptime for every domain you own and alerts you when something changes. Free for 3 domains.