DKIM (DomainKeys Identified Mail, RFC 6376) lets a receiver verify that a message was sent by someone authorised by a domain and was not modified in transit. It is the most reliable way to pass DMARC.
How it works
- Your sending service holds a private key. When it sends a message, it hashes selected headers and the body and signs the result, adding a
DKIM-Signature:header. - The header names the signing domain (
d=) and a selector (s=). - The receiver looks up the public key at
<selector>._domainkey.<domain>and checks the signature.
google._domainkey.example.com. TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqh..."
Selectors
A selector is just a name that lets a domain publish several keys at once: one per sending service, or an old and a new key during rotation. That is also why DKIM cannot be checked from a domain name alone, the way SPF and DMARC can: you need the selector, which appears in the DKIM-Signature: header of a message you received.
Setting it up
For each service that sends as your domain:
- Find its DKIM or "domain authentication" setting. Google Workspace, Microsoft 365 and every serious bulk-mail tool have one.
- Add the DNS records it gives you, usually a TXT or CNAME at a
_domainkeyname. - Switch signing on, then send a test message and check its headers for
dkim=passwithheader.d=your domain.
Use 2048-bit RSA keys where the service offers them; 1024-bit keys are considered weak. Rotate keys occasionally by publishing a new selector before retiring the old one.
DKIM and DMARC
DMARC passes when DKIM passes for a domain aligned with the From: address. If a service signs with its own domain (d=sendgrid.net) rather than yours, the signature is valid but does not help your DMARC. Setting up DKIM "for your domain" in the service is what fixes that.
