What is DKIM? DKIM signatures explained for IT professionals
DKIM (DomainKeys Identified Mail) is an email authentication mechanism that lets a sending server attach a cryptographic signature to each message. Receiving servers verify the signature against a public key published in the sender's DNS, which proves the message really came from that domain and was not altered in transit.
How DKIM works
When a mail server sends a DKIM-signed message, it:
- Selects the headers and body content to sign.
- Computes a hash and signs it with the domain's private key.
- Adds the result as a
DKIM-Signatureheader on the message.
The receiving server reads the signature header, fetches the matching public key from DNS, and verifies the hash. If the content was modified anywhere along the way, or the key does not match, verification fails.
Unlike SPF, DKIM survives forwarding. The signature travels with the message, so a forwarded email still verifies as long as the signed content is untouched. This is why DKIM alignment is usually the more reliable path to DMARC compliance.
The DKIM-Signature header
A typical signature header looks like this:
DKIM-Signature: v=1; a=rsa-sha256; d=example.com; s=selector1;
c=relaxed/relaxed; h=from:to:subject:date;
bh=Base64BodyHash...; b=Base64Signature...
| Tag | Meaning |
|-----|---------|
| v=1 | DKIM version. |
| a= | Signing algorithm, usually rsa-sha256 or ed25519-sha256. |
| d= | The signing domain. This is what DMARC checks alignment against. |
| s= | The selector: which DNS key record to look up. |
| h= | The headers included in the signature. |
| bh= | Hash of the message body. |
| b= | The signature itself. |
Selectors and the DNS record
The public key lives in a DNS TXT record at <selector>._domainkey.<domain>. For the header above, the receiver queries:
selector1._domainkey.example.com
Selectors let one domain publish many keys at the same time. Each sending service gets its own selector, so Google Workspace, your marketing platform, and your helpdesk can all sign as your domain without sharing keys. This is also what makes key rotation possible: publish a new key under a new selector, switch signing over, then retire the old record.
Key length and rotation
Use 2048-bit RSA keys. 1024-bit keys are still common but are considered too weak for new deployments. Some DNS providers struggle with long TXT values; split the record into multiple quoted strings rather than shortening the key.
Rotate keys periodically. A leaked private key lets an attacker sign mail as your domain until the DNS record is removed. Rotating once or twice a year, and immediately after any suspected compromise, limits that exposure.
DKIM and DMARC alignment
A valid DKIM signature alone is not enough for DMARC. The signing domain (d=) must also align with the From domain the recipient sees:
- With
adkim=r(relaxed, the default), a subdomain match is enough:d=mail.example.comaligns withFrom: example.com. - With
adkim=s(strict), the domains must match exactly.
This matters most with third-party senders. Many services sign with their own domain out of the box (d=mailchimp.com), which passes DKIM but fails DMARC alignment for your domain. Almost all of them support custom domain signing; setting that up is usually the single biggest step toward DMARC enforcement.
Common DKIM mistakes
Leaving third-party senders on their default signature. Signed by d=sendgrid.net means no alignment with your domain. Configure custom DKIM in each service that sends on your behalf.
Broken records from copy-paste. Truncated keys, stray whitespace, or a provider quietly splitting the value can all make verification fail. Test after every change.
Forgetting a service entirely. If a sender has no DKIM and its SPF domain does not align either, its mail fails DMARC. Use DMARC aggregate reports to find these senders before you enforce.
Never rotating keys. A key generated five years ago by a former employee still signs valid mail for your domain today. Inventory your selectors and rotate on a schedule.