Why email lands in spam and how to fix it: SPF, DKIM, DMARC
Are your company's emails landing in spam, or not arriving at all? The cause is usually not the content. The recipient simply cannot check that the message really comes from you. Three DNS records solve this problem: SPF, DKIM and DMARC.
What the recipient checks
When a mail server receives a message, it looks at several things: whether the sending server was allowed to send on behalf of the domain, whether the message was changed on the way, and whether the sender's IP address is on a spam list. DNS records answer the first two questions.
SPF: who may send on your behalf
SPF is a TXT record in the domain's DNS. It lists the servers that may send email from your domain. An example for a domain whose mail is handled by a server on the same host:
yourdomain.com. TXT "v=spf1 mx a -all"
Each domain has only one SPF record. If you use an external sending service (for example for newsletters), add it with include: instead of creating a second record.
DKIM: a signature on each message
DKIM adds a cryptographic signature to every message. The public key sits in a TXT record under a name that includes a selector, for example default._domainkey.yourdomain.com. The recipient checks the signature and knows the message was not changed on the way. On a server with ISPConfig you generate the key in the panel and add the record in DNS.
DMARC: what to do when something doesn't match
DMARC ties SPF and DKIM together and tells the recipient what to do with a message that fails the checks. You add the record under the name _dmarc:
_dmarc.yourdomain.com. TXT "v=DMARC1; p=none; rua=mailto:[email protected]"
Start with p=none, which only observes. The reports show who sends email in your name. Once all legitimate messages pass, tighten the policy to p=quarantine, and then to p=reject.
Reverse DNS and IP reputation
The server's IP address should have a PTR record that points to the mail server's name, and that name should point back to the same IP. Without this, many recipients reject the mail. Keep an eye on the reputation of the IP address too: sending large volumes of spam, or messages to outdated addresses, quickly puts it on blocklists.
How to check that everything works
- Send a test message to a Gmail mailbox and choose "Show original". The headers show the SPF, DKIM and DMARC results.
- On mail-tester.com you get a test address. Send a message to it from your mailbox, and the service scores it from 0 to 10 and shows how it fares with spam filters.
- Check that the IP address is not on a blocklist before you start sending larger volumes.
- Review the DMARC reports regularly to catch unauthorised sending.
Checklist
- SPF record added and lists only the servers that really send mail.
- DKIM enabled and the key published in DNS.
- DMARC in observation mode, with an address for reports.
- PTR matches the mail server's name.
- The test message passes all three checks.
Not sure which record goes where, or would you rather we set it up for you? Write to us at [email protected] and we will check your domain.
The Chmura.tech team