Resources · Security guides · Security guide
SPF, DKIM and DMARC for mail your server sends
Without SPF, DKIM and DMARC, your password resets land in spam and anyone can send mail as your domain. Set all three, starting DMARC at p=none.
Check command
dig +short TXT example.com; dig +short TXT _dmarc.example.com
Copied.
Password resets, invoices and alert emails that land in spam are a support problem. Mail that anyone can send as your domain is a security problem: phishing your own customers with your name on it. Three DNS records fix both. Gmail and Yahoo require them for bulk senders.
SPF: which servers may send
One TXT record on the domain lists the senders you use:
example.com. TXT "v=spf1 include:_spf.your-mail-provider.com -all"
Use the include your provider documents. There can be only one SPF record per domain, and at most 10 DNS lookups inside it: merge providers into one record rather than adding a second.
DKIM: a signature on every message
Your mail provider gives you a selector and a public key to publish:
s1._domainkey.example.com. TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqh..."
If you send directly from the server with Postfix, use OpenDKIM to sign, and publish the key it generates. Prefer a transactional mail provider over sending from a VPS IP: VPS address ranges often have poor reputation.
DMARC: what receivers do when checks fail
Start in report-only mode:
_dmarc.example.com. TXT "v=DMARC1; p=none; rua=mailto:[email protected]; adkim=s; aspf=s"
Read the aggregate reports for two to four weeks. They show every source sending as your domain. When only your legitimate senders pass, move to p=quarantine, then p=reject.
Check
dig +short TXT example.com
dig +short TXT s1._domainkey.example.com
dig +short TXT _dmarc.example.com
Then send a message to a Gmail account and open "Show original": SPF, DKIM and DMARC should each say PASS.
Domains that never send mail
Parked domains get abused too. Publish v=spf1 -all and v=DMARC1; p=reject; on them.