What are SPF, DKIM and DMARC — and why your mail still lands in spam

An annoying moment. You wire up email from your app, send yourself a test — and find it in spam. You open the headers and see spf=pass, dkim=pass. Both checks green. Still spam.
This happens more often than you'd think. Because mail checks three things, not two — and the third one asks something the first two don't.
Let's sort out who does what.
Three records, three different questions
Email was born with no protection at all. The sender line in a message is just text, and anyone can type anything into it. Including [email protected].
To patch that, three mechanisms were bolted on top. All three live in DNS, as text records next to your domain. Each answers its own question:
- SPF — "is this server even allowed to send as me?"
- DKIM — "was the message altered on the way?"
- DMARC — "and what should I do if the first two don't line up?"
None of them looks at the text of your email. All three check origin.
SPF — the list of who's allowed
SPF (Sender Policy Framework) is one DNS line listing the servers allowed to send mail for your domain.
It looks roughly like this:
v=spf1 include:_spf.google.com include:sendgrid.net -all
In plain words: "Google's and SendGrid's servers may send as me; everyone else, no."
The receiving side sees the message, checks the sending IP, looks up your DNS and compares. Not on the list — a mark against you.
Two rakes everyone steps on:
- There must be exactly one SPF record. Two
v=spf1records on one domain isn't "two allowed systems", it's an error that breaks both. Services get added viainclude:. - SPF breaks on forwarding. A user forwards your mail to another mailbox, the IP changes, the check fails. It's a known hole, and it's why SPF alone isn't enough.
DKIM — a seal you can't fake
DKIM (DomainKeys Identified Mail) comes at it from the other side. The sending server signs the message cryptographically and puts the signature in a header.
The public key for verifying it lives in DNS too. The recipient grabs the key, recomputes the signature and compares.
Match — the message really is from your domain and wasn't rewritten in transit. No match — someone touched it.
Your mail service usually generates the key and hands you a ready record to paste. Minimum key length is 1024 bits, but 2048 is recommended.
Unlike SPF, DKIM survives forwarding: the signature travels inside the message and doesn't care about the IP.
DMARC — and that alignment thing
Now the third check, and why pass isn't always pass.
DMARC (Domain-based Message Authentication, Reporting and Conformance) does two jobs. It tells the recipient what to do with failing mail, and it demands that the domains match.
That second part is the trap. It's not enough for SPF and DKIM to simply pass. The domain in the From field — the one a human sees — must match the SPF domain or the DKIM signing domain. That's called alignment.
An example. You send through a mail service. It signs messages with its own domain, mail.service.com. DKIM passes: the signature is honest. But your From field says [email protected]. Different domains, no alignment, DMARC fails — with both checks green.
The fix is the service's "sending domain" setup: you add a couple of CNAME records and it starts signing as you.
The DMARC record itself is simple. The part that matters is the policy:
p=none— do nothing, just send me reportsp=quarantine— put suspicious mail in spamp=reject— refuse it at the door
Always start with p=none. Watch the reports for a month, confirm your own mail isn't getting cut, and only then tighten.
What Gmail requires
Since 1 February 2024, Google turned this from good manners into requirements. Short version:
From every sender:
- SPF or DKIM — at least one of them;
- valid forward and reverse DNS records for the server;
- TLS in transit;
- spam complaint rate below 0.3%.
From bulk senders (5,000+ messages a day):
- SPF and DKIM — both;
- a DMARC record;
p=noneis enough; - the From domain aligned with at least one of the two;
- one-click unsubscribe for marketing mail.
The 5,000 threshold sounds far away, but look at the first block: it applies to everyone. Even if you send ten messages a day.
What to do right now
If you're just wiring up email, the order is:
- Get a domain and add it to your mail service — connecting a domain works the same way here.
- Paste the records it gives you: SPF, DKIM and the sending domain.
- Add DMARC with
p=noneand a mailbox for reports. - Send a test to Gmail and open "Show original". You should see three
passlines.
FAQ
Can I skip having my own domain?
Technically yes — many services let you send from their subdomain. But a message from [email protected] looks like spam to a human and to a filter. A domain costs pocket change, and you need one for DMARC anyway.
Why does my mail reach me but not my customer?
Most likely you're on different mail providers with different strictness. Another option: your own mailbox knows you and trusts you from past correspondence. Test on a clean external address, not your working one.
What is domain warm-up?
Gradually growing volume from a new domain: dozens of messages a day first, then hundreds. A sudden thousand from a domain that was silent yesterday is a classic spammer signature. For an app's transactional mail this rarely matters — the volume grows on its own.
The AI Architect 2027 course: step by step from computer basics to your own app and first customers. 543 short lessons on your phone.





