To set up an SPF record, publish a single TXT record on your domain that starts with v=spf1, lists every service allowed to send your mail, and ends with ~all or -all. For example, a domain that sends through Google Workspace and nothing else needs:
acme.com. TXT "v=spf1 include:_spf.google.com ~all"
SPF is defined in RFC 7208. The receiving server takes the domain from the envelope sender, looks up its SPF record and checks whether the connecting IP address is allowed.
Step by step
- List your senders. Mailbox provider, app email service, newsletter tool, CRM, helpdesk, billing. Check each one’s documentation for its SPF include or IP ranges.
- Check what already exists. Run
dig +short TXT acme.com. If a line starts withv=spf1, you will edit that record rather than adding a new one. - Build one record. Start with
v=spf1, add one mechanism per sender, end with~all. - Publish it as a TXT record on the domain (host
@in most DNS panels). - Test. Send a message to Gmail, choose Show original, and confirm SPF says PASS.
SPF syntax
| Part | Example | Meaning | Counts as a DNS lookup? |
|---|---|---|---|
| Version | v=spf1 |
Must come first | No |
include |
include:_spf.google.com |
Use another domain’s SPF record | Yes, plus any lookups inside it |
a |
a or a:mail.acme.com |
The domain’s A/AAAA addresses | Yes |
mx |
mx |
The domain’s mail servers | Yes |
ip4 / ip6 |
ip4:203.0.113.0/24 |
A literal address or range | No |
exists |
exists:%{i}.example.net |
Advanced macro check | Yes |
ptr |
ptr |
Reverse DNS check, do not use | Yes |
redirect |
redirect=_spf.acme.com |
Use another record instead | Yes |
all |
~all |
Matches everything else | No |
RFC 7208 says ptr “SHOULD NOT be published” because it is slow and unreliable (section 5.5).
Qualifiers: ~all, -all, ?all and +all
Every mechanism can carry a qualifier. It defaults to + (pass). The one that matters most is on all:
| Qualifier | Result | Use it? |
|---|---|---|
-all |
fail | Yes, once you are sure every sender is listed |
~all |
softfail | Yes, the usual starting point |
?all |
neutral | Rarely; treated like no SPF at all |
+all |
pass for any server | Never; it authorizes the whole internet |
SPF record examples
Google Workspace only:
v=spf1 include:_spf.google.com ~all
Microsoft 365 only:
v=spf1 include:spf.protection.outlook.com -all
Google Workspace plus your own server:
v=spf1 ip4:203.0.113.10 include:_spf.google.com ~all
A domain that sends no mail at all (protect parked domains from spoofing):
v=spf1 -all
Use the include value your provider documents; do not copy one from a blog without checking.
Multiple SPF records: merge them
The most common SPF mistake is having two records because two tools each said “add this SPF record”:
v=spf1 include:_spf.google.com ~all
v=spf1 include:mail.example-crm.com ~all
RFC 7208 says a domain “MUST NOT have multiple records” (section 3.2), and evaluation returns permerror when it finds more than one. SPF then fails for all your mail. Merge them:
v=spf1 include:_spf.google.com include:mail.example-crm.com ~all
The 10 lookup limit
Every include, a, mx, ptr, exists and redirect costs a DNS lookup, and includes can contain more includes. The total must stay at or below 10, or the result is permerror (section 4.6.4). If you are near the limit, read SPF too many DNS lookups.
Keep the record short in characters too. A TXT string is limited to 255 octets, so longer records are split into several quoted strings that receivers join without spaces. RFC 7208 also suggests keeping the whole answer under 450 octets so it fits in a single UDP DNS response.
Use a return-path subdomain for email services
SPF is checked on the envelope sender’s domain, not the From domain. Many email services let you set a custom return-path, such as send.acme.com, with its own SPF record. Amazon SES, for example, documents a MAIL FROM subdomain with an MX record and v=spf1 include:amazonses.com ~all (AWS docs).
Two benefits:
- Your main SPF record does not grow, so you stay under 10 lookups.
- SPF still aligns for DMARC, because
send.acme.comandacme.comshare an organizational domain under relaxed alignment.
Common SPF errors and what they mean
| Result in the header | Cause | Fix |
|---|---|---|
spf=none |
No SPF record on the envelope domain | Publish one |
spf=permerror |
Two records, over 10 lookups, or a syntax error | Merge, trim or correct the record |
spf=softfail |
Sender not listed and the record ends in ~all |
Add the missing service |
spf=fail |
Sender not listed and the record ends in -all |
Add the missing service |
spf=temperror |
A DNS timeout during the check | Usually transient; check your DNS host if it repeats |
Typos are a frequent cause of permerror: include: _spf.google.com with a space after the colon, v=spf1 written as v=SPF1 with a stray space, or a missing ~ before all. Paste the record into a checker after every edit.
What SPF does not do
SPF does not check the From address people see, and it usually breaks when mail is forwarded, because the forwarding server is not in your record. That is why you also need DKIM and DMARC. The SPF, DKIM and DMARC overview shows how they fit together.
Mailcandor and SPF
Mailcandor puts its SPF record and bounce MX on send.yourdomain, so you do not add anything to your main SPF record and it costs you no lookups there. You can check any domain’s SPF with our free tools.