SPF, DKIM and DMARC Explained: Stop Emails Going to Spam
Your website sends a password reset. The customer says it never arrived. You send a quote from your business email, and it lands in the client's spam folder. Nothing looks wrong on your side. The email left, so where did it go?
Most of the time, the answer is three small DNS records: SPF, DKIM and DMARC. They are how Gmail, Outlook and every other mail provider decide whether an email really comes from you. If one of them is missing or broken, your email gets treated like a stranger at the door.
We learned this the hard way on our own site. We moved our domain's DNS to Cloudflare, everything looked fine, and then our contact form alerts quietly stopped arriving. The bounce message said: 550 5.7.1 Email rejected per DMARC policy. The cause turned out to be a single setting on two records. More on that below, because it catches a lot of people.
This guide explains the three records in plain language, shows what correct ones look like, and lists the mistakes we see most often. No email background needed.
Last checked: November 11, 2026.
The short version
| Record | What it answers | Where it lives | One-line example |
|---|---|---|---|
| SPF | Which servers may send email for my domain? | TXT record on your domain | v=spf1 include:_spf.google.com ~all |
| DKIM | Was this email really signed by my domain, and unchanged? | TXT or CNAME at selector._domainkey |
v=DKIM1; k=rsa; p=MIIBIjAN... |
| DMARC | What should receivers do when the checks fail? | TXT record at _dmarc |
v=DMARC1; p=quarantine; rua=mailto:... |
A simple way to remember it:
- SPF is the guest list. It names the servers allowed to send on your behalf.
- DKIM is the wax seal. Each email carries a signature that proves it came from you and was not changed on the way.
- DMARC is the house rule. It tells receivers what to do with an email that fails, and sends you reports about it.
You want all three. Since 2024, Gmail and Yahoo require at least SPF or DKIM from everyone, and all three from anyone sending in bulk. Microsoft added similar rules for Outlook.com in 2025.
SPF: the guest list
SPF is one TXT record on your main domain. It lists every service that sends email with your domain in it. Here is a typical one for a business that uses Google Workspace for its inbox and SendGrid for its website and newsletter emails:
v=spf1 include:_spf.google.com include:sendgrid.net ~all
Read it left to right:
v=spf1says "this is an SPF record".- Each
include:adds a provider's list of servers. Your email provider tells you exactly what to put here (Microsoft 365 usesinclude:spf.protection.outlook.com, Zoho Mail usesinclude:zoho.com). ~allat the end means "anything else is suspicious". The stricter-allmeans "anything else is fake". Both are fine once DMARC is in place.~allis the safer place to start.
The SPF mistakes we see most
Two SPF records. You are only allowed one TXT record starting with v=spf1 on your domain. When you add a new email service, edit the existing record and add another include:. Don't create a second one. Two records count as an error, and receivers treat that like having no SPF at all.
Pointing at something that no longer exists. This is what bit us. Our old DNS host had set up SPF through a helper record with a name like dc-1a2b3c4d5e._spfm.example.com. When we moved to Cloudflare and cleaned up, the helper was deleted, but the main record still pointed at it. To a mail server, that's a broken SPF record. If you see an include: with a long random name on your own domain, check that it still resolves before you delete anything.
Too many lookups. Each include: can trigger more DNS lookups behind the scenes, and SPF allows at most 10. Stack up five or six email tools and you can cross that line without noticing. Remove services you no longer use, and check your record with a free SPF checker after every change.
DKIM: the wax seal
When your email provider sends a message, it adds a digital signature to it using a private key that only the provider has. The matching public key sits in your DNS. The receiving server looks up that key and checks the signature. If it matches, the email is genuinely from your domain and nobody changed it on the way.
The key lives at a special name made of a selector plus ._domainkey:
google._domainkey.yourdomain.com TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0B..."
s1._domainkey.yourdomain.com CNAME s1.domainkey.u1234567.wl123.sendgrid.net
The selector (google, s1, selector1, k1) is just a label, so each service can have its own key without clashing. Some providers give you the key itself as a TXT record. Others give you a CNAME that points to a key they host and rotate for you. Both work.
Unlike SPF, you can have many DKIM records, one per service. That is normal.
The DKIM mistakes we see most
Cloudflare's orange cloud on DKIM records. This was our main problem. When Cloudflare imports your records, it may turn on the proxy (the orange cloud) for CNAME records, including DKIM ones. A proxied record no longer points to the real key. To the outside world, it looks like a Cloudflare web address with no key behind it. Every signature check fails.
The fix takes ten seconds: edit each _domainkey record and switch it to DNS only (grey cloud). The same goes for any other mail-related CNAME or A record. Proxying is for websites, never for email.
Signing is not switched on. Adding the DNS record is only half the job. In most email services (Zoho, Google Workspace, Microsoft 365) you also have to press Verify or Enable on the DKIM page in the admin panel. Until you do, emails go out unsigned.
A key that got cut off. Long keys sometimes get truncated when someone copies them by hand or a DNS panel has a length limit. If the signature fails and the record exists, compare the key in DNS with the one your provider shows, character by character.
DMARC: the house rule
SPF and DKIM do the checking. DMARC decides what happens next. It is one TXT record at _dmarc.yourdomain.com:
v=DMARC1; p=quarantine; rua=mailto:[email protected]
p=is the policy for emails that fail:none: deliver them as normal, just report. Use this to start.quarantine: send them to spam.reject: bounce them outright.
rua=is where receivers send daily summary reports about who is sending email using your domain.
The idea that makes DMARC click: alignment
DMARC adds one rule that confuses most people. For an email to pass, SPF or DKIM must pass and match the domain in the "From" address your reader sees. That match is called alignment.
This is why newsletter tools work the way they do. When Brevo, Mailchimp or SendGrid send for you, the hidden bounce address usually belongs to their domain, so SPF checks their domain, not yours. SPF can pass and still not align. What saves the day is DKIM: they sign with your domain, using the _domainkey records they asked you to add. That aligned DKIM pass is what gets their emails through DMARC.
So if DKIM for a sending service breaks, and your policy is quarantine or reject, that service's emails will fail, even though "SPF passes". That is exactly what happened to our contact form.
How to roll out DMARC without breaking your email
- Start with
p=noneand arua=address. Nothing changes for delivery. - Read the reports for two to four weeks. A free DMARC report viewer makes the XML files readable. You'll see every service that sends as your domain, including ones you forgot about, like a CRM, a billing tool or an old contact form.
- Fix SPF and DKIM for each legitimate sender.
- Move to
p=quarantine. Watch for a week or two. - Move to
p=rejectwhen the reports show only your own services passing.
Starting straight at reject is how businesses lose invoices and password resets without noticing.
How to check your own setup in two minutes
The easiest way: Gmail. Send an email from your business address to a Gmail account. Open it, click the three dots (⋮) and choose Show original. At the top you'll see SPF, DKIM and DMARC, each with PASS or FAIL. Three passes means your setup is right.
From a terminal, you can look at the records directly:
dig +short TXT yourdomain.com # SPF lives here
dig +short TXT _dmarc.yourdomain.com # DMARC
dig +short TXT google._domainkey.yourdomain.com # DKIM (use your selector)
On Windows, nslookup -type=TXT yourdomain.com does the same job. Not sure of your DKIM selector? In Gmail's Show original, look for s= in the DKIM-Signature line. That's it.
Our free SPF, DKIM and DMARC checker tests all three records in one go. It follows every include:, counts the lookups, tries the common DKIM selectors and explains each problem in plain words, including a broken include left behind after a DNS move.
Moving your DNS? Use this checklist
Changing DNS provider is the moment email breaks most often, because records get missed, mangled or proxied during the import. Before you switch nameservers:
- Export or screenshot every record at your old provider, especially MX, every TXT and every
_domainkeyrecord. - After the import, compare them line by line. Imports regularly drop or change records.
- Set every mail record to DNS only if your new host offers a proxy. That covers MX targets,
_domainkeyCNAMEs and anymailorautodiscoverrecords. - Check there is still exactly one SPF record, and that every
include:still resolves. - Send a test to Gmail and check Show original right after the switch.
One more thing that will save you an anxious hour: after you fix a record, receivers may keep using the old, wrong answer for a while. With Cloudflare, a "nothing here" answer can be cached for up to 30 minutes. If the fix is right but the test still fails, wait half an hour and try again before changing anything else.
All three pass, but you're still in spam?
Then authentication is no longer the problem. Gmail is judging the email itself and your domain's track record. A few things help:
- Give it a few days. A domain that just changed its setup, or sends rarely, has little reputation yet. Normal emails that get opened and replied to build it.
- Mark it "Not spam" and add the sender to your contacts while testing. Gmail learns from that quickly.
- Write like a person. One-line test messages, all caps, lots of links or link shorteners look like spam. A normal greeting and a couple of sentences do not.
- Send newsletters through a proper service, with a working unsubscribe link, and only to people who asked for them. Gmail expects bulk senders to keep spam complaints well below 0.3%.
Security on your domain and your server go hand in hand. If you also run your own VPS, our checklist on securing a new Linux VPS in 30 minutes covers the server side.
FAQ
Do I need all three records? Yes. Some email gets through with only SPF, but Gmail, Yahoo and Outlook now expect SPF and DKIM, and DMARC for anyone sending in volume. Together they also stop scammers from sending fake emails in your name.
My newsletter tool says I don't need to add it to SPF. Is that right?
Usually, yes. Most newsletter services use their own bounce domain, so your SPF isn't checked for their emails at all. They pass DMARC through DKIM, which is why their DKIM records matter so much. Adding their include: doesn't hurt, as long as you stay under 10 lookups.
What does "550 5.7.1 rejected per DMARC policy" mean?
The receiving server checked SPF and DKIM, neither passed in a way that matched your domain, and your DMARC policy is reject, so it bounced the email. Check DKIM for the service that sent it first. It is the most common cause.
Should I use p=reject straight away?
No. Start with p=none, read the reports, fix every legitimate sender, then tighten to quarantine and later reject. Going straight to reject can silently block your own invoices and password resets.
Does any of this affect emails people send to me? Not directly. Receiving mail depends on your MX records. SPF, DKIM and DMARC are about proving the email you send is genuine. That said, broken DNS after a migration often hits MX records too, so check those while you're there.
Three small records, a few minutes of setup, and your emails stop looking like strangers at the door. If you only do one thing today, send yourself a test to Gmail and look at Show original. It tells you exactly where you stand.
Sources
The facts in this article were checked against these sources.
- RFC 7208: Sender Policy Framework (SPF) rfc-editor.org
- RFC 6376: DomainKeys Identified Mail (DKIM) rfc-editor.org
- RFC 7489: DMARC rfc-editor.org
- Google: email sender guidelines support.google.com
- Yahoo: sender best practices senders.yahooinc.com