Cybersecurity

What is an SPF Record and Why Do You Need One?

Discover how SPF records prevent email spoofing, improve deliverability, and why Gmail and Yahoo require SPF for bulk senders in 2025.

By Inventive HQ Team

An SPF (Sender Policy Framework) record is a single DNS TXT record that lists which mail servers are allowed to send email on behalf of your domain — defined by RFC 7208. When a receiving server accepts a message that claims to be from you@yourdomain.com, it looks up your domain's SPF record and checks whether the server that actually delivered the message is on your approved list. If the IP matches, the message passes SPF; if it does not, the message fails and is more likely to be rejected or dropped in spam. You need one because without it, anyone on the internet can forge your domain in the envelope of their spam and phishing — and since February 2024, Gmail and Yahoo outright require SPF for anyone sending bulk mail.

That is the summary an AI Overview will give you. What it can't show you is the mechanism most guides get wrong (SPF checks a hidden address, not the one in your inbox), the exact anatomy of a record you can copy, the failure that silently breaks authentication, and a generator that builds a valid record for your providers. Here is the part that actually keeps mail flowing.

How SPF actually works: the envelope, not the inbox

The single most misunderstood fact about SPF is which sender it validates. Every email carries two "from" addresses: the visible From: header your mail client displays, and a hidden envelope sender (the Return-Path / MAIL FROM) used during SMTP delivery. SPF checks the envelope sender's domain — not the From: address you see. That is why SPF alone cannot stop a phisher who puts your brand in the visible From: while using their own domain in the envelope. Closing that gap is DMARC's entire job: it requires the SPF-authenticated domain to align with the visible From: domain.

How an SPF check runs on an inbound email A sending server connects, the receiver reads the envelope sender domain, looks up that domain's SPF TXT record in DNS, and compares the sending IP against the authorized list to decide pass or fail. SPF evaluation on one inbound message Sending server IP 203.0.113.9 Receiving server reads envelope DNS SPF TXT record v=spf1 ... ~all

message lookup

Compare sending IP against authorized list IP is listed → PASS delivered normally IP not listed → FAIL rejected or marked (per ~all / -all)
Advertisement

Anatomy of an SPF record

An SPF record is one line, but every token matters. Here is a realistic record for a domain that sends through Google Workspace and SendGrid, broken down:

v=spf1 include:_spf.google.com include:sendgrid.net ip4:198.51.100.20 ~all
TokenTypeWhat it does
v=spf1VersionRequired first token. Marks this TXT record as SPF.
include:_spf.google.comMechanismDelegates authorization to Google's published SPF (Gmail/Workspace). Costs 1 DNS lookup (plus any nested).
include:sendgrid.netMechanismAuthorizes SendGrid's sending IPs.
ip4:198.51.100.20MechanismAuthorizes one specific IPv4 address (e.g. your own mail server). Costs zero DNS lookups.
~allQualifier + allCatch-all for everything not matched above. ~ = softfail.

The qualifier in front of all is the policy decision that people most often get wrong:

QualifierNameReceiver behavior for unlisted sendersWhen to use
-allHardfailReject unauthorized mailOnce DMARC reports confirm no legitimate mail fails
~allSoftfailAccept but mark as suspiciousStart here — safe default during rollout
?allNeutralNo opinion; treat as if no SPFAlmost never — provides no protection
+allPass-allAuthorize the entire internetNever. This authorizes spammers to spoof you

Build a valid record now

Rather than hand-assemble includes and risk a typo that silently breaks authentication, generate a record from your actual providers and paste it into DNS:

Loading interactive tool...

The two failures that quietly break SPF

Most broken SPF setups fail for one of two reasons, and neither throws an obvious error:

  1. More than one SPF record. A domain must publish exactly one v=spf1 TXT record. Publish two (easy to do when you add a new provider and paste a second line) and receivers return a permerror — which breaks SPF entirely rather than combining them. Always merge new include mechanisms into the existing record.
  2. The 10 DNS lookup limit. RFC 7208 caps evaluation at 10 DNS lookups. Every include, a, mx, ptr, and exists mechanism consumes lookups, and nested includes count recursively — a single include:_spf.google.com can hide several. Cross 10 and you get a permerror. Fixes: prefer ip4/ip6 mechanisms (zero lookups), drop unused providers, or "flatten" the record. We cover this in depth in The SPF 10 DNS Lookup Limit.

Forwarding is a third gotcha: when a mailbox forwards your message, the forwarding server's IP is not on your list, so SPF fails at the final hop. This is not a bug in your record — it is why SPF is never deployed alone. DKIM survives forwarding because it signs the message itself, and DMARC lets a pass on either SPF or DKIM authenticate the message.

Why you need SPF in 2025: Gmail and Yahoo made it mandatory

In February 2024, Gmail and Yahoo began enforcing bulk-sender requirements: any domain sending more than roughly 5,000 messages a day to their users must publish SPF and DKIM, and have a DMARC policy (at minimum p=none). Fall short and your mail gets rejected or filtered to spam at massive scale. Even below that threshold, mailbox providers weigh authentication heavily in placement decisions. SPF is no longer optional hygiene — it is table stakes for the inbox.

The takeaway: SPF is the "who is allowed to send" layer. It is cheap (one DNS record), but it only validates the hidden envelope sender, it breaks on forwarding, and it dies silently if you exceed 10 lookups or publish two records. Deploy it with ~all, watch your DMARC reports, tighten to -all, and layer DKIM and DMARC on top. That combination — not SPF alone — is what actually stops spoofing and protects deliverability.

Frequently Asked Questions

What is an SPF record?

An SPF (Sender Policy Framework) record is a single DNS TXT record, defined by RFC 7208, that lists the mail servers authorized to send email for your domain. When a receiving server gets a message claiming to come from your domain, it looks up your SPF record and checks whether the connecting server's IP address is on the approved list. If it is, the message passes SPF; if not, it fails or is treated as suspicious.

What does an SPF record look like?

A basic SPF record is a TXT record whose value starts with "v=spf1" and ends with an "all" mechanism, for example: "v=spf1 include:_spf.google.com include:sendgrid.net ~all". The include mechanisms delegate authorization to your email providers, and "~all" (softfail) tells receivers to accept but mark anything not listed. You publish exactly one such record on your root domain.

What is the difference between ~all and -all in SPF?

The qualifier before "all" sets the policy for servers not listed. "-all" is a hardfail — receivers should reject unauthorized mail. "~all" is a softfail — receivers should accept it but mark it suspicious. "?all" is neutral and provides essentially no protection. Start with "~all" while you confirm every legitimate sender is included, then tighten to "-all" once DMARC reports show no legitimate mail failing.

Does SPF check the From address I see in my inbox?

No, and this surprises people. SPF validates the hidden "envelope sender" (the Return-Path / MAIL FROM domain), not the visible "From:" header you see in your email client. That is why SPF alone cannot stop display-name spoofing. DMARC closes this gap by requiring the SPF-authenticated domain to align with the visible From domain.

What is the SPF 10 DNS lookup limit?

RFC 7208 caps SPF evaluation at 10 DNS lookups. Mechanisms like include, a, mx, ptr, and exists each consume lookups, and nested includes count recursively. Exceed 10 and receivers return a "permerror," which many treat as an SPF failure. Consolidate providers, use ip4/ip6 mechanisms (which cost zero lookups), or flatten your record to stay under the cap.

Do I need SPF if I already have DKIM and DMARC?

Yes. SPF, DKIM, and DMARC are layers, not alternatives. DMARC only passes when at least one of SPF or DKIM both authenticates and aligns with the visible From domain, so a robust setup wants both underneath. Gmail and Yahoo's 2024 bulk-sender rules explicitly require SPF, DKIM, and a DMARC policy for anyone sending more than 5,000 messages a day.

Can I have more than one SPF record on a domain?

No. A domain must publish exactly one SPF (v=spf1) TXT record. Two or more SPF records cause a "permerror" and break authentication entirely. If you add a new provider, merge its include mechanism into your existing record rather than publishing a second one.

How long does an SPF record take to work after I add it?

An SPF record takes effect as soon as the DNS TXT record propagates, which is usually minutes but can take up to the record's TTL (often a few hours). There is no separate "activation" — receivers query it live on each inbound message. Lowering the TTL before a change speeds up propagation.

Why is my legitimate email failing SPF?

The most common cause is a sending service (a CRM, invoicing tool, or marketing platform) whose IPs are not in your record. Forwarding also breaks SPF, because the forwarding server's IP is not yours — this is why DKIM and DMARC matter. Check your DMARC aggregate reports to see which IPs are sending as you, then add any legitimate ones with an include or ip4 mechanism.

SPFemail securityemail authenticationDNSanti-spoofing