DNS and authentication

How to set up an SPF record

Short answer

An SPF record is one TXT record on your domain that starts with v=spf1, lists the servers allowed to send mail for it, and ends with ~all or -all. Add an include for each email service, keep it to a single record and under 10 DNS lookups, and publish it on the domain used in the envelope sender. Many email services use their own return-path subdomain, so your main record stays short.

Last checked 16 November 2026

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

  1. 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.
  2. Check what already exists. Run dig +short TXT acme.com. If a line starts with v=spf1, you will edit that record rather than adding a new one.
  3. Build one record. Start with v=spf1, add one mechanism per sender, end with ~all.
  4. Publish it as a TXT record on the domain (host @ in most DNS panels).
  5. 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.com and acme.com share 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.

Questions

What does an SPF record look like?

A TXT record such as v=spf1 include:_spf.google.com ~all. It starts with v=spf1, lists allowed senders with mechanisms like include, ip4 and a, and ends with an all mechanism.

Can I have multiple SPF records?

No. RFC 7208 says a domain must not have more than one SPF record. Receivers that find two return permerror and SPF fails. Merge all mechanisms into one record.

Should I use ~all or -all?

~all (softfail) is the safer start while you confirm every sender is listed. Once DMARC reports show all legitimate mail passes, -all (fail) is stricter. With DMARC at enforcement, the practical difference is small.

Does SPF check the From address?

No. SPF checks the envelope sender (MAIL FROM, shown as Return-Path), not the From header people see. DMARC is what links SPF to the From address.

Do subdomains inherit the SPF record?

No. Each domain and subdomain is checked on its own. If mail is sent with send.acme.com as the envelope sender, send.acme.com needs its own SPF record.

Related

Send with someone on your side.

Unlimited domains on every plan, a person before any block, and 3,000 emails a month free. Tell us what you send and we set you up within one business day.