SPF, DKIM and DMARC, explained
Three DNS records decide whether your mail is trusted or sent to spam. What each one does, how they fit together, and the five mistakes that break them.
Email was designed without any way to prove who sent a message. The From line is just text, and anyone can type anything into it. SPF, DKIM and DMARC are the three DNS records added on top to fix that — and since 2024, when Gmail and Yahoo began requiring them of anyone sending in volume, they have stopped being optional.
If your mail is landing in spam, or somebody is sending phishing as your domain, the cause is very often in one of these three. Here is what each one does, how they fit together, and the mistakes that break them.
SPF: who may send
SPF (Sender Policy Framework) is a TXT record listing the servers allowed to send mail for your domain. A receiving server looks at the connection the message arrived on and checks whether it is on the list.
A typical record looks like v=spf1 include:_spf.yourprovider.com -all. The include pulls in your provider's list of servers, and the ending says what to do with anything else: -all means fail it, ~all means treat it as suspicious.
SPF has two weaknesses. It checks the hidden envelope sender, not the From address people see, so on its own it does not stop somebody showing your name. And it breaks when mail is forwarded, because the forwarding server is not on your list.
DKIM: who did send
DKIM (DomainKeys Identified Mail) signs each outgoing message with a private key held by your provider. The public half is published in DNS under a selector, and the receiver uses it to check that the message came from a server holding the key and was not changed on the way.
Because the signature travels inside the message, DKIM survives forwarding where SPF does not. That makes it the more reliable of the two.
DMARC: what to do when they fail
DMARC (Domain-based Message Authentication, Reporting and Conformance) is the record that makes the other two mean something. It asks for alignment: the domain that passed SPF or DKIM has to match the domain in the visible From line. That closes the gap where a spammer passes SPF for their own domain while showing yours.
It also sets a policy — p=none to only watch, p=quarantine to send failures to spam, p=reject to refuse them — and names an address for aggregate reports, so you can see who is sending as your domain.
The mistakes that break them
- Two SPF records. A domain may have only one; with two, receivers treat SPF as broken. Merge them into a single record.
- Too many lookups. SPF allows at most ten DNS lookups while it is checked, and every include counts. Add enough newsletter and helpdesk tools and the record fails for everyone.
- Forgetting a sender. The billing system, the newsletter tool and the website's contact form all send as your domain. Each one needs to be in SPF or, better, signing with DKIM for your domain.
- Jumping straight to p=reject. Start at p=none, read the reports for a couple of weeks, fix every legitimate sender that fails, then move to quarantine and reject.
- No DMARC at all. Without it, receivers have to guess what you want, and the large ones increasingly guess spam.
How to check yours
Send a message to a Gmail address, open it, and choose Show original. Gmail lists the SPF, DKIM and DMARC result for the message at the top. Three passes and you are done; anything else names the record to look at.
On Ruber, all three are written and verified for a domain when you add it, and the domain page shows each record's state rather than leaving you to read headers.