Skip to content
DMARC Pulse

Learn

SPF Record Syntax: Mechanisms, Qualifiers and Examples

SPF record syntax explained: v=spf1, mechanisms, qualifiers, the 10-lookup limit and TXT record examples you can copy and adapt.

Reference

SPF record syntax is one line of text in a DNS TXT record: v=spf1, then mechanisms separated by spaces, normally ending with all. SPF (Sender Policy Framework) lists the servers allowed to send mail for a domain. A mechanism is a test against the sending server. Receiving servers run the tests from left to right and stop at the first match.

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

Here, ip4:192.0.2.10 allows one server, include:_spf.google.com allows Google Workspace, and ~all gives every other server a softfail result.

SPF record format

An SPF record is a version followed by terms, separated by spaces. A term is a mechanism or a modifier.

  • The record must begin with exactly v=spf1.
  • A mechanism can start with a qualifier: +, -, ~ or ?. With none, it means +.
  • Mechanism and modifier names are case-insensitive.
  • A syntax error anywhere returns permerror, the result for a record that could not be interpreted.
  • With no match and no redirect, the result is neutral.

Where a DNS SPF record goes

Publish it as a TXT record (DNS type 16) at the exact name it covers. RFC 7208 discontinued the separate SPF record type. Each name takes one v=spf1 record, and every subdomain that sends mail needs its own.

Receivers check the domain in the MAIL FROM address, the envelope sender used during delivery. It can differ from the From address people see. They can also check the HELO name the sending server announces.

Mechanisms

Mechanism Matches DNS lookup
all Every server. Goes last. No
ip4:192.0.2.0/24 An IPv4 address or range. No
ip6: An IPv6 address or range. No
a, a:mail.example.com Addresses in the name's A or AAAA records. Yes
mx, mx:example.com Addresses of that domain's MX hosts. Yes
include:_spf.google.com Another domain's SPF check, when it returns pass. Yes, plus terms inside it
exists: A name built with macros (message placeholders), when an A record exists for it. Yes
ptr Reverse DNS of the sender. RFC 7208 says not to publish it. Yes

Plain a or mx uses the domain being checked. Without a / length, ip4: and ip6: mean one address.

SPF record and A record: the a mechanism

An SPF record is always a TXT record. The a mechanism authorizes the addresses in a name's A (IPv4) or AAAA (IPv6) records. Plain a authorizes whatever address your domain resolves to, so avoid it when your website sits on shared hosting or a content delivery network.

Qualifiers and -all

Qualifier Result Meaning
+ pass Authorized.
? neutral No statement. Treated exactly like none, the no-record result.
~ softfail Probably not authorized. Receivers should not reject on this alone.
- fail Not authorized. Local policy decides what happens.

Google recommends ~all. Microsoft recommends -all for Microsoft 365 domains that also use DKIM (message signing) and DMARC (the policy built on SPF and DKIM). It suggests starting a new record with ~all until you know every source. See how SPF fail and softfail differ in delivery.

Caution: with -all, receivers may reject mail from any server you forgot to list. Move to it only after your DMARC aggregate reports show every real sender passing SPF.

Modifiers

redirect=_spf.example.com hands the check to another record, for domains under the same administration. It counts as a lookup, and receivers ignore it if the record has all. exp= names a TXT record explaining failed mail. Using either twice returns permerror.

Limits

  • 10 DNS lookups per check. include, a, mx, ptr, exists and redirect count, as do terms inside included records. Past 10, the result is permerror.
  • 2 void lookups. RFC 7208 says receivers should limit queries that return no data to two. Past that, the result is permerror.
  • 255 octets (bytes) per string. A TXT record can hold several strings, joined with no added space.

Examples

Enter the record as the TXT value at your DNS host, using your own IP addresses. If the name already has a v=spf1 record, edit it instead of adding another. List all your senders before you publish, and read the -all caution above. The SPF generator builds one from your senders.

SPF TXT record example for one provider

Google Workspace alone:

TXT
v=spf1 include:_spf.google.com ~all

Microsoft 365 alone (Microsoft documents other values for GCC High, DoD and 21Vianet):

TXT
v=spf1 include:spf.protection.outlook.com -all

Several senders in one record

Google documents this form for Google Workspace plus Microsoft 365:

TXT
v=spf1 include:_spf.google.com include:spf.protection.outlook.com ~all

A server of your own goes in by its public IP address:

TXT
v=spf1 ip4:203.0.113.25 include:spf.protection.outlook.com -all

A domain that sends no mail

TXT
v=spf1 -all

Microsoft documents this for parked domains. Caution: on a domain that does send mail, it fails every message.

Splitting a long record

Keep the space inside the first string, because receivers join strings without adding spaces:

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

This is the zone-file form. In a DNS panel, the name and type go in their own fields. Some panels want each string in quotes and others take one value and split it automatically, so check your DNS host's help.

Common mistakes

  • Two v=spf1 records on one name. The check returns permerror. Merge them into one and keep every sender.
  • Mechanisms after all. They are never tested, so v=spf1 ~all include:_spf.google.com leaves Google out.
  • A misplaced space or equals sign. The space in include: spf.protection.outlook.com is a syntax error. include=spf.protection.outlook.com reads as an unknown modifier, so receivers ignore it and the service loses its authorization.
  • An include: with no record behind it. The check returns permerror. Take each value from the provider's documentation.
  • Too many lookups. Nested includes count, so fewer than 10 include: terms does not guarantee you are under the limit.
  • Publishing +all. Every IP address passes.

Check it now

Validate SPF and count DNS lookups

Frequently asked questions

What is the correct format of an SPF record?
One TXT record that starts with v=spf1, followed by mechanisms and modifiers separated by spaces. Example: v=spf1 include:_spf.google.com ~all. Publish it at the domain it covers and end it with all, so the default result is explicit.
Is an SPF record a TXT record or an A record?
A TXT record. RFC 7208 allows only the DNS TXT type (type 16). The a mechanism inside an SPF record is a separate thing: it authorizes the IP addresses in the A or AAAA records of a domain.
What does -all mean in an SPF record?
-all gives a fail result to every server that no earlier mechanism matched, and the receiving server may reject that mail. ~all gives a softfail instead, and RFC 7208 says that result alone should not cause rejection. Google recommends ~all. Microsoft recommends -all for Microsoft 365 domains that also use DKIM and DMARC.
How long can an SPF record be?
Each string in a TXT record holds up to 255 octets (bytes). An SPF record can contain several strings, which receivers join without adding spaces. RFC 7208 advises keeping the DNS name plus all TXT records on that name under 450 octets so answers fit in UDP packets. Google's Admin Help lists 255 characters for an SPF record.
Does the order of mechanisms matter?
Yes. Receivers test mechanisms from left to right and stop at the first match. Any mechanism placed after all is ignored, so all goes last. Order can also decide whether a check reaches the limit of 10 DNS lookups.

Sources consulted

RFC 7208 §3 SPF Records
checked 2026-11-08
RFC 7208 §3.4 Record Size
checked 2026-11-08
RFC 7208 §4.6.2 Mechanisms
checked 2026-11-08
RFC 7208 §5.1 all
checked 2026-11-08
RFC 7208 §5.2 include
checked 2026-11-08
RFC 7208 §5.3 a
checked 2026-11-08
RFC 7208 §5.4 mx
checked 2026-11-08
RFC 7208 §5.6 ip4 and ip6
checked 2026-11-08
RFC 7208 §5.7 exists
checked 2026-11-08
RFC 7208 §6.1 redirect
checked 2026-11-08
RFC 7208 §6.2 exp
checked 2026-11-08
RFC 7208 §7 Macros
checked 2026-11-08
RFC 7208 §8.1 None
checked 2026-11-08
RFC 7208 §8.2 Neutral
checked 2026-11-08
RFC 7208 §8.4 Fail
checked 2026-11-08
RFC 7208 §8.5 Softfail
checked 2026-11-08
RFC 7208 §8.7 Permerror
checked 2026-11-08

Related pages

Keep it healthy

Know the moment something breaks

Point your DMARC reports to DMARC Pulse and see who sends email as your domain, what fails and why — with a calm alert when anything changes.

Free plan: 1 domain, no credit card.