Quick SPF reference
SPF (Sender Policy Framework) is a TXT record in your domain’s DNS that lists every IP address authorized to send email on behalf of your domain. Receiving servers check it on every inbound message to decide whether your mail is legitimate or spoofed.
| What it is | A DNS TXT record naming authorized sending sources for your domain. |
| Where it lives | Your domain’s DNS zone, at the apex (or subdomain). One SPF record per domain, never two. |
| Record type | TXT (the dedicated SPF type was deprecated in RFC 7208). |
| Required by | Gmail, Yahoo, Microsoft, all major ISPs. Mandatory for bulk senders since February 2024. |
| Defined in | RFC 7208 (current), supersedes RFC 4408. |
| Tools | Free SPF Generator · Free SPF Checker |
What is an SPF record?
An SPF record is a single line of text published in your domain’s DNS that answers one question: which servers are allowed to send email claiming to be from this domain? Receiving mail servers query it during every inbound SMTP handshake. If the connecting IP appears in the list, the message passes SPF. If it doesn’t, the message is treated according to the policy you chose: silently accepted, marked as suspicious, or rejected outright.
SPF is one of the three pillars of modern email authentication, alongside DKIM and DMARC. Without it, anyone on the internet can forge your domain in the MAIL FROM envelope and send spam, phishing, or malware in your name. With it correctly published, receivers have a cryptographic-grade way to reject impersonation attempts before they ever reach an inbox.
If you send more than 5,000 messages per day to Gmail or Yahoo addresses, SPF is no longer optional, it is mandatory, alongside DKIM and a DMARC policy of at least p=none. Missing or broken SPF can sink an entire campaign overnight. See Google & Yahoo bulk sender rules for the full checklist.
How SPF works, step by step
Every time someone sends mail claiming to be from your domain, this is what happens behind the scenes:
- The sending server connects to the receiving mail server and issues
MAIL FROM: user@yourdomain.com. - The receiving server extracts the domain (
yourdomain.com) from the envelope sender. - The receiving server queries DNS for the TXT record at
yourdomain.com, looking for one beginning withv=spf1. - The SPF record is evaluated against the connecting IP address. The receiver walks left-to-right through each mechanism (
ip4,include,a,mx…) until it finds a match. - A result is returned: pass, fail, softfail, neutral, none, permerror, or temperror. The receiver then applies its own policy (and your DMARC policy if one exists) to decide whether to deliver, quarantine, or reject.
The whole check takes milliseconds. But the rules that produce the result are subtle, and that’s where most mistakes hide.
SPF record syntax: anatomy of a TXT record
An SPF record is a single string starting with the version tag v=spf1, followed by mechanisms separated by spaces, ending with an all qualifier. Here is a real-world example for a domain that sends mail through Google Workspace plus Mailgun:
v=spf1 include:_spf.google.com include:mailgun.org -allRead left to right, this says: “version 1; the IPs that Google publishes for Workspace are authorized; the IPs that Mailgun publishes are authorized; everything else, hard-fail.”
SPF mechanisms
| Mechanism | What it does | Example |
|---|---|---|
v=spf1 | Version tag, always first. | v=spf1 |
ip4: | Authorizes a single IPv4 address or CIDR block. | ip4:203.0.113.5 or ip4:203.0.113.0/24 |
ip6: | Authorizes a single IPv6 address or block. | ip6:2001:db8::1 |
include: | Imports another domain’s SPF record. Counts as 1 DNS lookup. | include:_spf.google.com |
a | Authorizes the IP(s) in your A record. | a or a:mail.example.com |
mx | Authorizes the IPs of your MX servers. | mx or mx:example.com |
exists: | Passes if the lookup returns any A record. | exists:%{i}.spf.example.com |
all | Catch-all, must come last. Paired with a qualifier. | -all or ~all |
SPF qualifiers
Each mechanism can be prefixed with a qualifier that tells the receiver what to do when the mechanism matches:
| Qualifier | Result | Use case |
|---|---|---|
+ (default) | Pass | Authorize. Implied if no qualifier is written. |
- | Fail (hard) | Reject. Use -all once you are confident no legitimate mail comes from outside your include list. |
~ | Softfail | Accept but mark as suspicious. Use ~all while testing. |
? | Neutral | No opinion. Equivalent to no SPF protection at all. Avoid. |
Real-world SPF examples by provider
Copy these as starting points. Each is a valid record for a domain sending only through that provider. If you use several, combine them (see “multiple services” below).
Google Workspace
v=spf1 include:_spf.google.com ~allMicrosoft 365 / Outlook for Business
v=spf1 include:spf.protection.outlook.com -allSendGrid
v=spf1 include:sendgrid.net ~allMailchimp / Mandrill
v=spf1 include:servers.mcsv.net -allMailgun
v=spf1 include:mailgun.org ~allAmazon SES
v=spf1 include:amazonses.com ~allPostmark
v=spf1 a mx include:spf.mtasv.net ~allBrevo (ex-Sendinblue)
v=spf1 include:spf.brevo.com ~allMultiple services combined
If you send through Google Workspace for corporate email and SendGrid for transactional and Mailchimp for newsletters:
v=spf1 include:_spf.google.com include:sendgrid.net include:servers.mcsv.net -allWatch the 10-lookup limit (next section), each include counts as one, and providers often nest further includes inside their own records.
The 10-DNS-lookup limit (where most SPF records break)
Probably the single most misunderstood part of SPF. An SPF record is allowed a maximum of 10 DNS lookups during evaluation. Exceed that and the entire record returns permerror, meaning none of your mail authenticates, regardless of which IPs you authorized.
What counts as a lookup:
- Every
include:mechanism, and recursively, everyinclude:inside that domain’s own SPF record. - Every
a,mx,exists:,ptr, andredirect=mechanism. ip4:andip6:do NOT count, they don’t require a DNS query.
A record like v=spf1 include:_spf.google.com include:sendgrid.net include:servers.mcsv.net include:mailgun.org include:amazonses.com include:_spf.salesforce.com include:spf.protection.outlook.com -all looks reasonable, but Google’s _spf.google.com alone nests several deeper includes, and you can blow past 10 lookups with just 5 visible includes.
Fix: use our free SPF checker to count your actual lookups. If you’re over, you have several options: restructure with subdomains, flatten, or use a managed SPF service (the trade-offs of each are covered in the dedicated guide).
How SPF fits into DMARC
SPF authenticates the envelope sender (the MAIL FROM address used during SMTP negotiation). DMARC requires that the envelope domain and the visible From: header domain match, this is called SPF alignment.
A message can pass SPF (the connecting IP is authorized) but still fail DMARC (the SPF-authenticated domain does not match the From header domain). Forwarders are the classic case: a mailing list relays your message from its own IP, so SPF checks against the list’s domain, not yours, DMARC alignment breaks. That is exactly why ARC (RFC 8617) exists, and why a DMARC policy without DKIM is fragile.
For the full picture, see our Email Delivery Infrastructure guide.
Common SPF mistakes (and how to avoid them)
- Two SPF records on the same domain. If you add a second TXT starting with
v=spf1, the entire SPF lookup returnspermerror. Merge into one record. - Using
+allor noall.+alltells receivers everyone is authorized, equivalent to no SPF at all. Always end with~allor-all. - Exceeding the 10-lookup limit. Discussed above. The most common reason for “SPF stopped working after I added a new ESP.”
- Forgetting subdomains.
marketing.example.comneeds its own SPF if you send from it. Otherwise it inherits nothing, and DMARC may fail. - Using deprecated
ptr. Theptrmechanism is officially deprecated in RFC 7208 because it is slow and unreliable. Don’t use it. - SPF string longer than 255 characters. A single DNS string is capped at 255 chars. Longer records must be split into multiple concatenated strings inside one TXT record, most DNS hosts handle this automatically, but a manual edit can break it.
- Trusting SPF alone. SPF doesn’t authenticate the From header, doesn’t survive forwarding, and doesn’t protect attachments. Pair it with DKIM and DMARC, every time.
- Not updating after switching ESPs. Cancelled SendGrid but left
include:sendgrid.netin your record? You’re now linked to a service you no longer control. Audit twice a year. - Hard-failing (
-all) before you’re ready. Going straight to-allcan block legitimate edge cases (a forgotten internal mailer, a vendor’s notification service). Start with~all, monitor DMARC reports for 2-4 weeks, then tighten. - Treating
includeas an inheritance.include:other.comonly imports SPF rules, not the domain itself. Ifother.com‘s SPF returns fail, your evaluation continues; anincludeonly stops on match.
How to test your SPF record
Before you publish, and after every change, verify your record:
- Use the free SMTPedia SPF Checker at smtpedia.com/free-spf-record-checker. It validates syntax, counts your DNS lookups, expands every
include, and flagspermerrorconditions. - Send a test email to a personal Gmail or Outlook account. Open the message, view the full headers, and look for an
Authentication-Resultsline containingspf=pass. - Query DNS directly with
digornslookup:
You should see exactly one string starting withdig TXT example.com +shortv=spf1. - Monitor DMARC aggregate reports once DMARC is in place. They show real-world SPF pass/fail rates by source IP, which catches issues no checker can simulate.
SPF FAQ
Can I have more than one SPF record for the same domain?
No. Publishing two TXT records that both start with v=spf1 causes the entire SPF evaluation to return permerror, and your mail fails to authenticate. If you need to authorize multiple services, merge their include mechanisms into a single record.
What’s the difference between ~all and -all?
~all is softfail: messages from unauthorized IPs are accepted but flagged as suspicious. -all is hardfail: they should be rejected. Use ~all while testing or rolling out, then move to -all once you’re sure every legitimate sending source is authorized.
Does SPF check the From header?
No. SPF only checks the envelope sender (MAIL FROM), not the From: header your recipients see. This is why SPF alone cannot prevent display-name spoofing or visible-From spoofing, DMARC alignment plus DKIM is what closes that gap.
How long does it take for an SPF change to propagate?
DNS propagation depends on your TXT record’s TTL (time to live). Most DNS hosts default to 3,600 seconds (1 hour), meaning your changes are fully visible worldwide within an hour. Before making changes, lower the TTL to 300 seconds for fast rollback. After the change settles, restore the longer TTL.
Do I need SPF if I use Gmail or Outlook for business email?
Yes. Google Workspace and Microsoft 365 sign messages on your behalf, but you must still publish an SPF record at your own domain authorizing their sending infrastructure. Without it, recipients can’t verify that the message really came from you, and Gmail and Yahoo will throttle or reject your mail above 5,000 messages per day.
My SPF passes but emails still go to spam. Why?
SPF is just one signal. Inbox placement also depends on DKIM, DMARC alignment, sender reputation, spam-complaint rate, list hygiene, content quality, and engagement history. Use a domain auditor like the SMTPing checker to see all signals at once and identify which one is weakest.
Final words
SPF is the simplest piece of email authentication to set up, and one of the most consequential to get wrong. A correct record protects your domain, your recipients, and your reputation. A misconfigured one quietly sends your campaigns to the spam folder while you wonder what changed.
Three habits keep an SPF record healthy: (1) audit it whenever you add or remove a sending service, (2) count your DNS lookups every quarter, (3) read your DMARC reports, they tell you the truth about what’s actually happening in the wild.
Once SPF is solid, move on to DKIM and DMARC. Together, the three close the door on virtually all forms of domain impersonation.
Clean your list before you send.
SMTPing catches what regex misses: disposable addresses, role-based emails, catch-all domains, syntax errors, dead mailboxes and known traps. 13 validation types, 25 free checks daily, no card required.
About the Author

Alaa · LinkedIn
Email infrastructure specialist with 8+ years of hands-on experience in SMTP, deliverability, and email verification. I’ve configured and troubleshot mail systems across Postfix, Exchange, and cloud relays, managed IP reputation and warmup campaigns, and built verification pipelines processing millions of addresses. My work spans DNS authentication (SPF, DKIM, DMARC, BIMI), bounce handling, blocklist monitoring, and compliance frameworks including CAN-SPAM and GDPR. I write every article on SMTPedia to give email professionals, developers, and marketers the accurate, RFC-grounded reference they need.
About SMTPedia
SMTPedia is an independent email industry reference covering SMTP, IMAP, POP3, email deliverability, marketing platforms, DNS authentication, and email verification. Every article is researched from official provider documentation, IETF RFCs, and industry best practices. Settings and configurations are verified quarterly.
We are cited as a source by ChatGPT, Microsoft Copilot, and thousands of email professionals worldwide. Learn more about our editorial process.

