SPF, DKIM and DMARC Explained: Stop Your Emails Landing in Spam
SPF, DKIM and DMARC explained in plain English, with copy-ready DNS records, Gmail and Yahoo sender rules, and a safe rollout plan to keep email out of spam.
By Devma Hosting Team · · 9 min read
SPF, DKIM and DMARC are three DNS records that prove your email really comes from your domain. SPF lists the servers allowed to send mail for you. DKIM adds a tamper-evident signature to every message. DMARC tells receiving servers what to do when those checks fail, and sends you reports about it. Gmail, Yahoo and Outlook now require all three for bulk senders, so missing or broken records can send legitimate email to spam or get it rejected outright.
Key takeaways
- SPF authorizes sending servers, DKIM signs messages, and DMARC sets the policy and reporting on top of both.
- Gmail requires every sender to use SPF or DKIM. Bulk senders (5,000+ messages a day to Gmail) need SPF, DKIM and DMARC, with a minimum DMARC policy of
p=none. - A domain can have only one SPF record, and it must stay within 10 DNS lookups.
- DMARC passes only when SPF or DKIM passes and matches the domain in your visible From address.
- Roll out DMARC in stages, from
p=nonetop=quarantinetop=reject, and read the reports before each step.
Why do legitimate emails land in spam?
Email was designed without built-in sender verification. Anyone can put you@yourcompany.com in the From line of a message. Receiving servers therefore lean on authentication to tell your real mail apart from spoofers and phishers. If your domain can't prove who is allowed to send for it, your messages look the same as a forgery.
The big mailbox providers have made this explicit:
- Gmail's sender guidelines took effect in February 2024. Google's FAQ says that starting in November 2025, "Gmail is ramping up its enforcement on non-compliant traffic."
- Yahoo's sender requirements closely mirror Gmail's.
- Microsoft's Outlook.com policy has applied since May 5, 2025. Domains sending more than 5,000 emails a day must comply with SPF, DKIM and DMARC. Non-compliant mail goes to Junk first and may then be rejected with error
550 5.7.515.
What is SPF?
SPF (Sender Policy Framework) is a TXT record at your domain that lists the servers and services allowed to send email for it. The receiving server looks up the domain in the message's envelope sender, also called the Return-Path or MAIL FROM, and checks whether the sending IP address is on the list. That's a different address from the From line your recipients see.
A basic SPF record for a domain that sends only through Google Workspace looks like this:
example.com. 3600 IN TXT "v=spf1 include:_spf.google.com ~all"
The record is built from mechanisms, each with an optional qualifier:
| Part | Meaning |
|---|---|
v=spf1 |
Identifies the record as SPF. Must come first |
ip4: / ip6: |
Authorizes a specific IP address or range |
include: |
Authorizes the servers listed in another domain's SPF record |
a / mx |
Authorizes the IPs in your domain's A or MX records |
-all |
Fail: everything not listed is unauthorized |
~all |
Softfail: probably unauthorized, accept but mark |
?all |
Neutral: no assertion. Use only for testing |
Three rules from the SPF standard, RFC 7208, trip people up constantly:
- One record only. If a domain publishes more than one SPF record, the check returns
permerror. To add a new service, edit your existing record instead of creating a second one. - Ten DNS lookups maximum.
include,a,mx,ptr,existsandredirecteach count toward the limit, and so do the lookups inside nested includes.ip4,ip6andalldon't count. Exceed the limit and SPF fails withpermerror. - Avoid
ptr. The RFC says this mechanism "SHOULD NOT be published."
Here's how merging works in practice:
; Wrong: two SPF records cause a permerror
example.com. IN TXT "v=spf1 include:_spf.google.com ~all"
example.com. IN TXT "v=spf1 include:mail.esp.example ~all"
; Right: one merged record
example.com. IN TXT "v=spf1 include:_spf.google.com include:mail.esp.example ~all"
~all or -all? Google's Workspace example uses ~all. Microsoft recommends -all for Microsoft 365 domains, used together with DKIM and DMARC. DMARC counts both as an SPF failure. Starting with ~all and tightening later is a safe path.
What is DKIM?
DKIM (DomainKeys Identified Mail) adds a digital signature to every message you send. Your mail server signs selected headers and the body with a private key. You publish the matching public key in DNS, and receivers use it to confirm the message really came from your domain and wasn't altered in transit.
The public key lives at a selector under _domainkey, as defined in RFC 6376:
; Public key shortened for readability
s1._domainkey.example.com. 3600 IN TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu5..."
Every signed message carries a DKIM-Signature header. Its d= tag names the signing domain and its s= tag names the selector. A few practical points:
- Each sending service has its own key. Your mailbox provider, newsletter tool and help desk each give you a selector and a record to publish. Some use CNAME records that point to keys they manage for you.
- Use strong keys. RFC 6376 requires at least 1024-bit RSA keys for long-lived keys. Gmail requires 1024 bits or more and recommends 2048 bits where your provider supports it.
- DKIM usually survives forwarding. The signature travels with the message, so it keeps verifying as long as nobody modifies the signed content. SPF, by contrast, often breaks when mail is forwarded.
- Revoke old keys by publishing the selector with an empty
p=value.
What is DMARC?
DMARC (Domain-based Message Authentication, Reporting and Conformance) ties SPF and DKIM to the address your recipients actually see. A message passes DMARC when either:
- SPF passes and the envelope domain aligns with the From domain, or
- DKIM passes and the
d=signing domain aligns with the From domain.
"Aligned" means the domains match. By default the match is relaxed: news.example.com aligns with example.com because they share the same organizational domain.
The DMARC record lives at _dmarc under your domain. The common tags are:
| Tag | What it does |
|---|---|
v=DMARC1 |
Version. Required, and must come first |
p= |
Policy: none (monitor), quarantine (treat as suspicious) or reject |
rua= |
Where to send daily aggregate reports, e.g. mailto:dmarc@example.com |
sp= / np= |
Policy for subdomains / for subdomains that don't exist |
adkim= / aspf= |
Alignment mode: r (relaxed, the default) or s (strict) |
t= |
Test mode (t=y) in the updated standard |
The DMARC standard itself changed recently. In May 2026, RFC 9989 replaced the original RFC 7489. It keeps v=DMARC1, so existing records still work. It also removes the old pct percentage tag and adds t for test mode and np for non-existent subdomains. Receivers are still catching up, so stage your rollout by policy level rather than relying on either tag.
A typical rollout looks like this:
; Stage 1: monitor only
_dmarc.example.com. 3600 IN TXT "v=DMARC1; p=none; rua=mailto:dmarc-reports@example.com"
; Stage 2: failures go to spam
_dmarc.example.com. 3600 IN TXT "v=DMARC1; p=quarantine; rua=mailto:dmarc-reports@example.com"
; Stage 3: failures are rejected
_dmarc.example.com. 3600 IN TXT "v=DMARC1; p=reject; rua=mailto:dmarc-reports@example.com"
How do SPF, DKIM and DMARC work together?
| SPF | DKIM | DMARC | |
|---|---|---|---|
| Verifies | The sending server is authorized | The message is signed and unaltered | SPF or DKIM passed and aligns with From |
| DNS location | example.com |
selector._domainkey.example.com |
_dmarc.example.com |
| Checks this domain | Envelope sender (Return-Path) | d= in the signature |
Visible From header |
| Survives forwarding | Often not | Usually, if content is unchanged | Depends on DKIM |
A common failure shows why alignment matters. Say you send newsletters through an email marketing service. SPF passes, but for the service's own bounce domain, which doesn't match your From address. Unless the service also signs with DKIM using your domain, DMARC fails. That's why every reputable email platform has a "domain authentication" setup step. Don't skip it.
What do Gmail, Yahoo and Outlook require?
| Gmail | Yahoo | Outlook.com | |
|---|---|---|---|
| Who | All senders, plus stricter rules for 5,000+ messages a day | All senders, plus stricter rules for bulk senders | Domains sending 5,000+ messages a day |
| Authentication | All: SPF or DKIM. Bulk: SPF and DKIM | All: SPF or DKIM. Bulk: SPF and DKIM | SPF and DKIM must pass |
| DMARC | Bulk: at least p=none, aligned with SPF or DKIM |
Bulk: at least p=none, and DMARC must pass |
At least p=none, aligned with SPF or DKIM |
Gmail and Yahoo add a few more rules:
- Spam complaints. Keep your spam rate below 0.3%. Gmail suggests staying under 0.1%.
- One-click unsubscribe. Bulk marketing mail must support it through the
List-UnsubscribeandList-Unsubscribe-Postheaders. Yahoo says to honor unsubscribes within 2 days, and Google recommends 48 hours. - DNS and transport. Both require valid forward and reverse DNS (PTR) for sending IPs. Gmail also requires TLS.
Google also notes that once you've met the bulk-sender threshold, you're "permanently considered" a bulk sender.
How to set up SPF, DKIM and DMARC step by step
-
List everything that sends as your domain. Include your mailbox provider, website contact forms, newsletter platform, CRM, invoicing tool and help desk. Forgotten senders are the main cause of DMARC failures.
-
Publish or fix your SPF record. Create one record that includes every service, and check the lookup count.
-
Turn on DKIM in every service. Publish each selector record the service gives you, then confirm the service shows it as verified.
-
Publish DMARC at
p=nonewith aruaaddress you actually monitor, or one belonging to a DMARC reporting service. If reports go to a different domain, that domain must publish an authorization record. Reporting services set this up for you. -
Read the reports for a few weeks. Look for legitimate sources that fail SPF or DKIM alignment, and fix them.
-
Tighten the policy. Move to
p=quarantine, watch for problems, then move top=reject. -
Protect domains that never send email. Spammers love parked domains:
example.net. 3600 IN TXT "v=spf1 -all" _dmarc.example.net. 3600 IN TXT "v=DMARC1; p=reject" example.net. 3600 IN MX 0 .
The last line is a "null MX" record (RFC 7505). It tells other servers the domain doesn't accept mail.
How to check your SPF, DKIM and DMARC records
Query DNS directly from a terminal:
dig +short TXT example.com # SPF
dig +short TXT s1._domainkey.example.com # DKIM (replace s1 with your selector)
dig +short TXT _dmarc.example.com # DMARC
Then send a test message to a Gmail address, open it, and choose Show original. Gmail shows whether SPF, DKIM and DMARC passed for that message. If you'd rather not use the command line, the free DNS lookup tool shows the same records in your browser.
Common SPF, DKIM and DMARC mistakes
- Adding a second SPF record instead of editing the first.
- Blowing past 10 lookups by stacking includes for every tool you've ever tried. Remove services you no longer use.
- Forgetting your website. Contact forms that send through the web server's built-in mail function often aren't covered by SPF or DKIM. Send them through your mail provider's SMTP instead.
- Jumping straight to
p=rejectbefore reading reports. You might block your own invoices. - Using
+all, which authorizes the entire internet to send as you. - Running your own mail server without reverse DNS. On a VPS, set a PTR record for your sending IP. Our VPS vs shared hosting guide explains when self-managing a server makes sense.
Get your email authentication right the first time
The free SPF and DMARC generator builds both records from the mail providers and DMARC policy you pick, and checks the 10-lookup limit for you. Once they're published, you can check them with the DNS lookup tool. If you'd rather not touch DNS at all, Devma Business Email sets up SPF, DKIM and DMARC for you, with plans from $1.49 per mailbox per month.
Frequently asked questions
Do I need SPF, DKIM and DMARC for a small business domain?
Yes. Gmail requires every sender to use at least SPF or DKIM, and senders of 5,000 or more messages a day to Gmail must use SPF, DKIM and DMARC. Even at low volume, having all three makes your mail far easier for receivers to trust and makes your domain much harder to spoof.
What DMARC policy should I start with?
Start with p=none and a rua address so you receive reports without affecting delivery. Once the reports show that all of your legitimate mail passes and aligns, move to p=quarantine and then to p=reject. Gmail, Yahoo and Outlook all accept p=none as the minimum for bulk senders.
Can a domain have two SPF records?
No. If a domain publishes more than one SPF record, the SPF check returns a permanent error (permerror). Merge every service into a single record that starts with v=spf1 and ends with one 'all' mechanism.
Why does DMARC fail when SPF passes?
DMARC requires alignment as well as a pass. SPF checks the hidden envelope sender (Return-Path), so if your email service uses its own bounce domain, SPF can pass for that domain while the visible From address uses yours. Turn on DKIM signing with your own domain in that service to fix it.
How long do SPF, DKIM and DMARC changes take to work?
New records are usually visible within minutes to a few hours. Changes to existing records can take as long as the record's TTL (time to live), often one hour or more. Check with a DNS lookup tool before sending test messages.
