SPF Mechanisms: include, ip4, mx, a, all Explained
Complete reference for every SPF mechanism and qualifier. Learn what include, ip4, ip6, mx, a, exists, ptr, all, redirect, and exp do in your SPF record.
An SPF record is a list of mechanisms — instructions that tell receiving mail servers which IP addresses are authorized to send email for your domain. Each mechanism checks the sender's IP in a different way, and the first match determines the result. Once you've built your record, you can verify it with SPF Record Check.
This is the complete reference. Every mechanism, every qualifier, every modifier.
Quick Reference
| Mechanism | What It Checks | DNS Lookup? | Common Use |
|---|---|---|---|
| include | Another domain's SPF record | Yes | Third-party email services |
| ip4 | IPv4 address or range | No | Your own mail servers |
| ip6 | IPv6 address or range | No | Your own mail servers |
| a | A/AAAA record of a domain | Yes | Web server that also sends email |
| mx | MX record hosts of a domain | Yes | Servers listed in your MX records |
| exists | Whether a domain resolves | Yes | Advanced macro-based checks |
| ptr | Reverse DNS of sender IP | Yes | Deprecated — do not use |
| all | Everything (catch-all) | No | Default policy at end of record |
The include Mechanism
include is the most common mechanism. It tells the receiving server to also check the SPF record of another domain. If the sender's IP passes the included domain's SPF record, it passes yours too.
v=spf1 include:_spf.google.com -all
This says: "Check Google's SPF record. If the sender's IP is authorized by Google, it's authorized by me."
Key details:
- Each
includecosts at least 1 DNS lookup, plus any lookups within the included record - If the included domain's SPF record doesn't exist, the result is
permerror includeis not the same as copying the other record's contents — only apassresult from the included record counts as a match. Afailfrom the included record doesn't produce a fail in yours; evaluation just continues to the next mechanism
Think of include as "also ask this domain." If that domain says "yes, this IP is authorized," your record says yes too. If that domain says "no," your record doesn't say no — it just moves on to the next mechanism.
Common Include Values
Here are the include values for popular email services:
- Google Workspace:
include:_spf.google.com - Microsoft 365:
include:spf.protection.outlook.com - SendGrid:
include:sendgrid.net - Mailchimp:
include:servers.mcsv.net - Amazon SES:
include:amazonses.com - Mailgun:
include:mailgun.org - Postmark:
include:spf.mtasv.net - Zendesk:
include:mail.zendesk.com - Freshdesk:
include:email.freshdesk.com - HubSpot:
include:spf.hubspot.com(check current docs)
The ip4 Mechanism
ip4 matches against a specific IPv4 address or CIDR range. No DNS lookup required.
v=spf1 ip4:203.0.113.50 -all
You can also specify a range:
v=spf1 ip4:203.0.113.0/24 -all
This authorizes all 256 addresses from 203.0.113.0 to 203.0.113.255.
When to use it:
- Your own mail server has a static IP
- A sending service gives you dedicated IPs instead of an include value
- You want to authorize a specific server without a DNS lookup
Use the narrowest range possible
Don't authorize a /16 range when you only use one IP. Every IP you authorize is an IP that could be used to pass your SPF check. Use the exact IP or the smallest CIDR range that covers your servers.
The ip6 Mechanism
Identical to ip4 but for IPv6 addresses. No DNS lookup required.
v=spf1 ip6:2001:db8::1 -all
With a prefix length:
v=spf1 ip6:2001:db8::/32 -all
If your servers send email over IPv6, you need ip6 mechanisms alongside your ip4 ones. Many organizations forget this and wonder why SPF fails intermittently — it's because some connections use IPv6.
The a Mechanism
The a mechanism checks whether the sender's IP matches the A record (or AAAA record) of a domain.
v=spf1 a -all
Without a domain argument, a checks the current domain's A record. You can also specify a different domain:
v=spf1 a:mail.example.com -all
Or add a CIDR prefix:
v=spf1 a:mail.example.com/24 -all
When to use it: When the server at your domain's A record also sends email. Common for small sites where the web server and mail server are the same machine.
Cost: 1 DNS lookup.
Keep tabs on your SPF record
Monitor your SPF, DKIM, DMARC, and MX records daily. Get alerted when something breaks.
The mx Mechanism
The mx mechanism checks whether the sender's IP matches any of the domain's MX record hosts (after resolving the MX hostnames to IPs).
v=spf1 mx -all
This says: "If the sender's IP is one of my mail exchange servers, it's authorized."
You can specify a different domain or add a CIDR prefix:
v=spf1 mx:example.com/24 -all
When to use it: When your inbound mail servers also handle outbound sending. This is common with self-hosted mail setups.
Cost: 1 DNS lookup for MX records, plus additional lookups to resolve each MX hostname. The MX mechanism also has its own limit — no more than 10 MX records can be resolved.
The mx mechanism can be expensive in terms of DNS lookups. If you have 3 MX records, that's 1 lookup for the MX query plus up to 3 lookups to resolve the hostnames. Use ip4 instead if you know the exact IPs.
The exists Mechanism
The exists mechanism checks whether a given domain has an A record (resolves to any IP — the actual IP doesn't matter).
v=spf1 exists:%{i}.spf.example.com -all
The %{i} is a macro that expands to the sender's IP address. So if the sender's IP is 203.0.113.50, the server checks whether 203.0.113.50.spf.example.com has an A record.
When to use it: Advanced setups where you want per-IP authorization via DNS wildcards or dynamic records. This is rare in typical configurations.
Cost: 1 DNS lookup.
The ptr Mechanism (Deprecated)
The ptr mechanism does a reverse DNS lookup on the sender's IP and checks whether the resulting hostname belongs to the specified domain.
v=spf1 ptr:example.com -all
The ptr mechanism is officially deprecated in RFC 7208. Do not use it. It's slow (requires reverse DNS lookups), unreliable (many IPs don't have proper reverse DNS), and places unnecessary load on DNS infrastructure. Use ip4, ip6, or include instead.
The all Mechanism
The all mechanism matches everything. It's always placed last in the record as the catch-all for any IP that didn't match a previous mechanism.
The qualifier before all determines what happens to unmatched IPs:
| Syntax | Qualifier | Result | Recommendation |
|---|---|---|---|
| -all | Fail | Reject unauthorized senders | Best for production domains |
| ~all | Softfail | Flag but don't reject | Good during initial setup |
| ?all | Neutral | No opinion | Rarely useful |
| +all | Pass | Authorize everyone | Never use this |
-all (Hard Fail)
Recommended for domains where you've identified all sending sources. Tells receiving servers to reject email from unauthorized IPs.
~all (Soft Fail)
A softer stance. Use this when you're still figuring out all your sending sources. Receiving servers will typically flag the message but not reject it outright. Many organizations start with ~all and switch to -all once they're confident.
+all (Pass All)
This authorizes every IP address on the internet to send email as your domain. Never, ever use this. It's worse than having no SPF record because it explicitly says "anyone can send as me."
Qualifiers
Every mechanism can be preceded by a qualifier that determines the result when the mechanism matches:
+(Pass) — Default if no qualifier is specified. The IP is authorized.-(Fail) — The IP is explicitly not authorized.~(Softfail) — The IP is probably not authorized.?(Neutral) — No assertion is made about the IP.
You usually only see qualifiers on the all mechanism, but they can be applied to any mechanism:
v=spf1 +include:_spf.google.com -ip4:192.168.1.1 ~all
In practice, the + qualifier is almost never written explicitly because it's the default.
Modifiers
Modifiers are not mechanisms — they don't match IPs. They change how the SPF record is processed.
redirect=
The redirect modifier replaces the current SPF evaluation with the SPF record of another domain. Unlike include, a redirect completely hands off evaluation.
v=spf1 redirect=_spf.example.com
Key differences from include:
redirectis only processed if no mechanisms matchredirectreplaces the entire evaluation — the result of the redirected record becomes the final result- You cannot use
redirectandallin the same record (theallwould always match before redirect is reached) - Costs 1 DNS lookup
exp=
The exp modifier specifies a domain whose TXT record contains an explanation string. This explanation is included in bounce messages when SPF fails.
v=spf1 -all exp=explain.example.com
Where explain.example.com has a TXT record like:
"See https://example.com/spf for our email authentication policy"
This is rarely used in practice, but it can help recipients understand why their email was rejected.
Evaluation Order and Matching
Mechanisms are evaluated left to right. Here's how the full process works:
Start at the first mechanism
The receiving server begins with the leftmost mechanism in the record.
Check for a match
If the sender's IP matches the mechanism, apply the qualifier (default is pass). Return the result. Stop.
No match — move to the next mechanism
If the IP doesn't match, move to the next mechanism in the record.
All mechanisms exhausted
If no mechanism matched and there's a redirect modifier, follow the redirect. If there's no redirect, the default result is neutral.
Optimize your record order
Place ip4 and ip6 mechanisms before include mechanisms. IP checks are instant (no DNS lookup), so putting them first means your most common sending IPs are verified without any DNS overhead.
Putting It Together
Here's a real-world SPF record that uses multiple mechanism types:
v=spf1 ip4:203.0.113.0/24 ip4:198.51.100.50 include:_spf.google.com include:sendgrid.net mx ~all
Reading left to right:
- Is the IP in the
203.0.113.0/24range? Pass. - Is the IP
198.51.100.50? Pass. - Is the IP authorized by Google? Pass.
- Is the IP authorized by SendGrid? Pass.
- Is the IP one of our MX servers? Pass.
- Nothing matched. Softfail.
This record uses 3 DNS lookups (include x2 + mx x1), plus any nested lookups inside Google's and SendGrid's records. After setting up SPF, the next step is DKIM for message signing, followed by a DMARC policy to tie them together.
Related Articles
Monitor Your New SPF Record
You've created your SPF record — now make sure it keeps working. The Email Deliverability Suite watches your SPF, DKIM, DMARC, and MX records daily and alerts you when something breaks.
Never miss an SPF issue
Monitor your SPF, DKIM, DMARC and MX records daily. Get alerts when something breaks.
Start Monitoring