English · IndiaLog in
Rackwave Technologies
Request quote Free consultation
SPFUpdated 22 Nov 2026

SPF Record: Syntax, Examples and How to Fix Common Errors

A clear guide to SPF records: syntax, examples for common senders, the ten-lookup limit and how to check and fix errors.

Written by Arjun Mehta
  • Published19 Nov 2026
  • Read time7 min
  • Length1,514 words
Share this guide
SPF Record: Syntax, Examples and How to Fix Common Errors

An SPF record is a DNS entry that lists which servers are allowed to send email for your domain. When a receiving server gets a message, it checks that record and decides whether the sending IP address is authorised. This guide covers the syntax, working examples for common senders, the ten-lookup limit that breaks many setups, and how to check and fix your record.

Short answer: An SPF (Sender Policy Framework) record is a TXT record on your domain that starts with v=spf1 and ends with an all mechanism, for example v=spf1 include:_spf.google.com ~all. You may publish only one SPF record per domain, and it may trigger no more than ten DNS lookups.

What is an SPF record?

Sender Policy Framework is specified in RFC 7208. It exists because the SMTP protocol lets anyone claim any sender address. SPF gives domain owners a way to publish the list of systems that may send on their behalf, which makes email spoofing harder.

SPF checks the envelope sender, the address used in the SMTP MAIL FROM command, also called the return-path. It does not check the From address that people see in their mail client. That gap is closed by DMARC, which requires the two domains to align.

How SPF evaluation works

Diagram showing the SPF check: envelope sender, DNS TXT lookup, IP comparison and the pass, softfail or fail result
Figure 1. The receiver reads the SPF record for the MAIL FROM domain and compares the connecting IP with each mechanism.
  1. The sending server connects. The receiving server notes the connecting IP address and the domain in MAIL FROM.
  2. The receiver queries DNS. It looks up the TXT records for that domain and picks the one beginning with v=spf1.
  3. Mechanisms are evaluated left to right. Each mechanism, such as ip4, include or mx, is tested against the connecting IP until one matches.
  4. A result is returned. The qualifier on the matching mechanism, or the final all, produces pass, fail, softfail, neutral, temperror or permerror.

SPF record syntax explained

A record is a single line of text made of a version tag, mechanisms and a closing rule. Here is a typical example.

example.com.  IN  TXT  "v=spf1 ip4:203.0.113.10 include:_spf.google.com include:mailer.example.net ~all"
PartMeaningExample
v=spf1Version tag. Must come firstv=spf1
ip4 / ip6Authorise an address or rangeip4:203.0.113.0/24
aAuthorise the domain's A or AAAA recorda or a:mail.example.com
mxAuthorise the domain's mail serversmx
includePull in another domain's SPF policyinclude:_spf.google.com
existsMatch if a DNS name resolves (advanced)exists:%{i}._spf.example.com
redirectUse another domain's record entirelyredirect=_spf.example.com
allCatch-all, always last~all or -all

Qualifiers: plus, minus, tilde and question mark

A symbol in front of a mechanism sets the result when it matches. With none, plus is assumed.

QualifierResultWhat it tells the receiver
+PassThis sender is authorised
-FailReject or treat as unauthorised (hard fail)
~SoftfailProbably unauthorised; accept but mark
?NeutralNo assertion either way

Most organisations end with ~all while they are still discovering all of their senders, then move to -all once the list is complete. When DMARC is enforced, the difference between the two matters less, because DMARC policy decides what happens to failures.

SPF record examples for common senders

Always copy the include value from your provider's current documentation, because hostnames can change. These examples show the shape of a correct record.

SetupExample record
Google Workspace onlyv=spf1 include:_spf.google.com ~all
Microsoft 365 onlyv=spf1 include:spf.protection.outlook.com ~all
Workspace plus a bulk senderv=spf1 include:_spf.google.com include:spf.sender.example ~all
Own server plus providerv=spf1 ip4:203.0.113.10 include:spf.sender.example -all
Domain that sends no emailv=spf1 -all

Parked domains need SPF too. A domain that never sends mail should publish v=spf1 -all. Attackers prefer unprotected lookalike and parked domains, so this single record removes an easy target.

The ten DNS lookup limit

RFC 7208 allows at most ten DNS-querying terms during one evaluation. The mechanisms include, a, mx, ptr, exists and the redirect modifier each count, and so do any lookups nested inside an include. Exceed the limit and the receiver returns permerror, which most systems treat as a failure.

This is the most common reason a record that looks correct still fails. Each SaaS tool you add, such as a CRM, helpdesk, newsletter tool and invoicing system, usually adds an include, and some providers' records contain several lookups of their own.

How to reduce lookups

  • Remove unused includes. Audit every sender and delete tools you no longer use.
  • Replace includes with ip4 or ip6 for static infrastructure you control. These cost no lookups.
  • Move senders to subdomains. Send marketing mail from a subdomain with its own SPF record so each record stays small.
  • Avoid ptr. It is slow, unreliable and discouraged by the specification.
  • Use SPF flattening carefully. Flattening converts includes to IP lists, but it must be refreshed automatically or it will go stale when providers change addresses.

One domain, one SPF record, ten lookups. Most SPF failures are a breach of one of those three rules.

How to create and publish an SPF record

  1. List every sender. Include your mailbox provider, marketing platform, transactional service, CRM, support desk and any servers you run.
  2. Collect each provider's SPF value. Use the include or IP ranges given in their documentation.
  3. Build one record. Start with v=spf1, add each mechanism and finish with ~all.
  4. Publish it as a TXT record. Add it at the root of the domain in your DNS provider. If a record already exists, edit it instead of adding a second one.
  5. Test and monitor. Send test messages, read the Authentication-Results header for spf=pass and review DMARC reports for unexpected sources.

How to check an SPF record

You can inspect a record from the command line with a single query.

dig +short TXT example.com
# expected output
"v=spf1 include:_spf.google.com ~all"

For a full evaluation that counts lookups and flags syntax errors, use an online SPF checker. For real message results, open a delivered test email and look for spf=pass in the headers of the receiving mailbox.

Common SPF errors and fixes

ProblemCauseFix
Multiple SPF recordsTwo TXT records start with v=spf1Merge them into one record
permerror: too many lookupsMore than ten DNS termsRemove includes, use ip4, split by subdomain
Missing senderA tool sends mail but is not in the recordAdd its include and retest
softfail on valid mailRecord lacks the sending IPAdd the IP range or provider include
Record over 255 charactersSingle TXT string too longSplit into quoted strings in the same record
Passes SPF, fails DMARCReturn-path domain does not match FromConfigure a custom return-path or rely on aligned DKIM

If you send through a dedicated SMTP service, use a custom return-path on your own subdomain so SPF passes and aligns with your From domain. This is also a prerequisite for a clean SMTP server setup.

SPF, DKIM and DMARC together

SPF alone does not stop spoofing of the visible From address, and it can break when mail is forwarded because the forwarder's IP is not in your record. DKIM survives forwarding because the signature travels with the message. DMARC then requires at least one of the two to pass and align. Treat them as one system and configure all three.

1SPF record allowed per domain
10DNS lookups before permerror
3Standards to configure: SPF, DKIM, DMARC

SPF and email forwarding

Forwarding is the classic weakness of SPF. When a message is forwarded, the forwarder's server connects to the final recipient, so the connecting IP address is the forwarder's, not yours. Your SPF record does not list it, and the check fails even though the original message was genuine. Mailing lists and some security gateways behave the same way.

This is why DKIM matters. A DKIM signature is attached to the message itself and usually stays valid through a simple forward, so DMARC can still pass on the DKIM result. Sender-side fixes include signing every message with your own domain, and using a custom return-path so SPF aligns for direct delivery. Receiver-side techniques such as ARC help preserve the original results across trusted forwarders.

Keeping SPF healthy over time

An SPF record is not a one-off task. Teams adopt new tools, switch providers and retire old systems, and each change can leave stale entries or push the record past the lookup limit. A short quarterly review prevents most surprises.

  • Re-check the lookup count after adding or removing any sending tool.
  • Confirm with each provider that its include value is still current.
  • Compare the record with your DMARC reports to spot senders you forgot.
  • Document who owns the record so changes are not made by guesswork.

Not sure your SPF record is safe?

We audit SPF, DKIM, DMARC and sender reputation across your domains and give you a prioritised fix list.

Request an email authentication audit

Read next: Email Bounce: Hard vs Soft Bounces, Codes and Fixes · What Is DMARC? Policies, Reports and a Safe Rollout Plan · Email Warm Up: How to Warm a New IP or Domain Safely

Frequently asked questions

What is an SPF record?

An SPF record is a TXT entry in your domain's DNS that lists the servers allowed to send email for that domain. Receiving mail servers read it to decide whether a message from your domain came from an authorised source.

What does a basic SPF record look like?

A basic record looks like v=spf1 include:_spf.google.com ~all. It begins with the version tag v=spf1, lists authorised senders using mechanisms such as include or ip4, and ends with an all mechanism that sets the default result.

How do I check my SPF record?

Query the TXT record with a command such as dig +short TXT yourdomain.com, or use an online SPF checker that validates syntax and counts DNS lookups. To confirm real-world results, send a test message and look for spf=pass in its headers.

How many SPF records can a domain have?

Only one. If a domain publishes two TXT records that start with v=spf1, receivers return a permanent error. Merge all senders into a single record.

What is the SPF 10 lookup limit?

RFC 7208 caps SPF evaluation at ten DNS-querying terms, counting include, a, mx, ptr, exists and redirect, including nested ones. Going over produces permerror, which usually causes SPF to fail.

What is the difference between ~all and -all?

The ~all ending is a softfail: unauthorised mail should be treated with suspicion but is usually still accepted. The -all ending is a hard fail: unauthorised mail should be rejected. Many teams start with ~all and move to -all when every sender is accounted for.

Does SPF stop email spoofing on its own?

No. SPF checks the envelope sender, not the visible From address, and it can fail on forwarded mail. Combine it with DKIM and a DMARC policy so receivers can act on the domain people actually see.

Do I need an SPF record if I only use Google Workspace or Microsoft 365?

Yes. Both services publish an include value that you must add to your domain's SPF record. Without it, mail from your domain is more likely to be flagged or rejected.

Was this guide helpful?Your answer helps us decide what to improve. It is not linked to you.

#SPF record#email authentication#DNS#DMARC#DKIM#email deliverability

About the author

Arjun Mehta

Integration Architect

Arjun designs and builds integration architecture connecting CRM, ERP, and custom systems, with a specific focus on API-led connectivity patterns using MuleSoft.

Integration & APIs (MuleSoftREST/Bulk APIs)

Ready to put AI and data to work?

Book a free consultation and leave with a plan, not a pitch.

Get a free consultationRequest quote