Three records, three questions
- SPF
Is the server that sent this email allowed to send on behalf of this domain? The record is a list of allowed servers.
- DKIM
Was the email's content changed on the way, and does it really come from this domain? The mail server signs every message with a key, and the public key is in DNS.
- DMARC
What to do with an email that passed neither SPF nor DKIM, and where to send reports about such emails?
Example records
This is what the records can look like for a domain that sends email through one provider. Your email provider gives the exact SPF value and the DKIM record in its documentation.
; SPF: only the email provider's servers may send email from the domain company.com. TXT "v=spf1 include:_spf.mail-provider.com -all" ; DKIM: the public key given by the provider (the selector name comes from the provider too) selector._domainkey.company.com. TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkq..." ; DMARC: stage 1, reports only, no effect on delivery _dmarc.company.com. TXT "v=DMARC1; p=none; rua=mailto:dmarc@company.com"
A domain can have only one SPF record. When you add another service that sends email, you add it to the existing record instead of creating a second one. Two SPF records are an error that makes both stop working.
A safe DMARC rollout, step by step
- List every service that sends email from the domain
Employees' mailboxes, the newsletter, the invoicing system, the shop, the website form, the CRM. It's easy to forget one.
- Set up SPF and DKIM for each of them
Every service has instructions in its documentation. Check sending with a test email.
- Turn on DMARC with p=none
Emails arrive as before, and you get reports on who sends on behalf of your domain.
- Review the reports for a few weeks
If you see one of your services failing the checks, fix its configuration. If you see unknown servers, those are spoofing attempts.
- Tighten the policy
First p=quarantine (suspicious mail to spam), and when everything is clean, p=reject (suspicious mail rejected).
DMARC reports are XML files that aren't very readable for people. There are free and paid tools that turn them into clear summaries.
Terms from this guide
- SPF
A DNS record listing the servers allowed to send email on behalf of a domain.
- DKIM
A digital signature the mail server adds to every email. The recipient checks it with the public key stored in the domain's DNS.
- DMARC
A DNS record that tells recipients what to do with an email that fails SPF and DKIM, and where to send reports.
Questions and answers
How do I know whether my domain has these records?
The simplest way is a free DMARC and SPF testing tool, or send an email to a Gmail mailbox and use “Show original” to see the SPF, DKIM and DMARC results.
Is this enough to keep emails out of spam?
It's the foundation, without which it's much harder. Content, domain reputation and whether recipients mark messages as spam also play a part.
Can p=reject block my own emails?
Yes, if one of the services sending on your behalf doesn't have correct SPF or DKIM. That's why p=none and reports come first, and tightening only after checking.
Sources and documentation
- RFC 7208: SPFrfc-editor.org
- RFC 6376: DKIMrfc-editor.org
- RFC 7489: DMARCrfc-editor.org
- Gmail: email sender guidelinessupport.google.com
- Microsoft 365: setting up DMARClearn.microsoft.com
- dmarc.org: DMARC overviewdmarc.org