DKIM (DomainKeys Identified Mail) is an authentication method that adds a digital signature to outgoing email. The receiving server checks the signature against the public key you publish in your domain's DNS. If the signature matches, two things are proven: the message really left a server that manages your domain, and it wasn't changed on the way.
Unlike SPF, it's tied to the message itself rather than the sending server's IP address. So when a message is forwarded to another address, SPF breaks but the DKIM signature stays valid.
How does DKIM work?
- Your email service generates a key pair. The private key stays secret at the service; the public key is added to DNS as a TXT record.
- For every outgoing message, the service signs a hash of the headers and body with the private key and adds a
DKIM-Signatureheader. - That header names the signing domain (
d=example.com) and the selector (s=google). - The receiving server reads the public key from the TXT record at
google._domainkey.example.comand verifies the signature.
In the message headers the recipient sees the result as dkim=pass header.d=example.com. In Gmail you can check this with "Show original" on a message.
What is a selector?
A selector is a label that lets one domain use several DKIM keys. Each sending service uses its own selector, so Google Workspace and your newsletter service can sign with the same domain without touching each other's keys.
google._domainkey.example.com. TXT "v=DKIM1; k=rsa; p=MIIBIjANBg..."
s1._domainkey.example.com. CNAME s1.domainkey.u12345.wl.sendgrid.net.
selector1._domainkey.example.com. CNAME selector1-example-com._domainkey.example.onmicrosoft.com.
You can't "list" selector names from DNS; you can only ask for a known name and see whether a key exists. Our lookup tool tries 18 common selectors. If you don't know yours, look at the s= value in the DKIM-Signature header of a message you sent and enter it in the tool's "Try your own DKIM selector" field.
Structure of a DKIM record
| Tag | Meaning |
|---|---|
v=DKIM1 | Version. Optional but recommended. |
k=rsa | Key type. The default is rsa; the newer, shorter ed25519 keys aren't supported by every receiver yet. |
p= | The public key in Base64. If left empty (p=), the key counts as revoked. |
t=y | Test mode. Receivers don't penalise failed signatures. Remove it once setup is done. |
t=s | The signature is valid only for exactly this domain, not for subdomains. |
How do you create a DKIM record?
You don't generate the DKIM key yourself; the service that sends your email does, and gives you the record to add to DNS. Where to find it in common services:
| Service | Where | Record |
|---|---|---|
| Google Workspace | Admin console, Apps, Gmail, Authenticate email | TXT, selector google |
| Microsoft 365 | Microsoft Defender portal, Email authentication settings, DKIM | Two CNAMEs: selector1 and selector2 |
| Zoho Mail | Admin console, Domains, Email configuration, DKIM | TXT, a selector you choose |
| cPanel | Email Deliverability | TXT, selector default |
| Plesk | Domain, Mail settings, Use DKIM to sign outgoing mail | TXT, selector default |
After adding the record, most services need you to click "Enable DKIM" or "Start authentication". Adding the record alone doesn't start signing.
Key length and rotation
For RSA keys, 2048 bits is today's standard. 1024-bit keys are still accepted but considered weak and may be penalised by some receivers; keys under 1024 bits are rejected. If your service offers a choice, pick 2048 bits.
Rotating keys once a year, or whenever you suspect a leak, is good practice. Add a second key under a new selector, switch the service to the new key and delete the old record a few days later. That's why Microsoft 365 uses two selectors (selector1, selector2).
DKIM and DMARC alignment
For a DKIM signature to count towards DMARC, the d= domain in the signature must match the domain in the message's From address. If a newsletter service signs with its own domain (d=sendgrid.net, say), DKIM passes but DMARC alignment fails. So you need to set up the service's "domain authentication" or "sign with a custom domain" option and add the DKIM records it gives you.
Common mistakes
- Adding the record to the wrong name. The name must be
google._domainkey, not@or_domainkey. - Breaking the key while copying. A space, line break or missing character in the middle of the long key breaks signature verification.
- Adding the record but not enabling the service. Even with correct DNS, there's no signature if the service hasn't started signing.
- Leaving test mode on. If the
t=ytag isn't removed, DKIM gives no protection. - Switching services and leaving the old key. Delete unused keys or revoke them with
p=.
