DKIM is a wax seal for email. The sender presses a signature into the message, the receiver checks it against a public key in DNS, and if the two agree, the letter is genuine and unopened. It is elegant. It is also the only part of email authentication that can be perfectly configured on Monday and broken on Tuesday by a legal disclaimer.
When DKIM fails, the header tells you so in a few clipped words: dkim=fail (body hash did not verify), or dkim=neutral (no key). Those words point to a small number of causes. This guide matches each message to its cause and its repair. If the mechanics are new to you, start with What Is DKIM?
First, read the signature
Every signed message carries a header like this:
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=example.com; s=mail2026;
h=from:to:subject:date:message-id;
bh=2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=;
b=AuUoFEfDxTDkHlLXSZEpZj79LICEps6eda7W3deTVFOk...Three tags do most of the diagnostic work:
d=is the signing domain. This is what DMARC compares with your From address.s=is the selector. The receiver fetches the public key frommail2026._domainkey.example.com.bh=is a hash of the body. If the body changes after signing, this no longer matches.
To see these for a real message, paste its headers into the email header analyzer. Then look up the selector with the DKIM checker. Most problems are settled by those two steps.
The error messages, decoded
| What the header says | What happened | Fix |
|---|---|---|
no key for signature | Nothing found at the selector’s DNS name | Publish the record; check the selector and hostname |
key revoked or empty key | Record exists with an empty p= | Publish the current key or sign with a live selector |
invalid public key / syntax error | Key truncated or malformed | Re-copy the full value from the provider |
body hash did not verify | Body changed after signing | Find what modifies the message in transit |
signature did not verify / bad signature | Signed headers changed, or wrong key published | Check for header rewriting; confirm key matches |
key too short / insecure key | Key under 1024 bits | Generate a 2048-bit key |
dkim=pass but dmarc=fail | Signed by a domain that is not yours | Configure custom-domain signing |
dkim=none | Message was not signed at all | Turn on signing at the sender |
Exact wording varies by receiver. The categories do not. Each is taken up below.
The key is missing
The receiver asked DNS for the key and came back empty-handed. There are four ways to arrange this.
The record was never published
Signing was switched on at the provider, and the DNS half was left for later. The provider signs faithfully; receivers find nothing. Many providers also do the reverse: they will not start signing until they detect the record, so the DNS is right and nothing is being signed.
The wrong selector
The message is signed with s=s2 and you published s1. Or you published the selector from the setup guide instead of the one your account was issued. Selectors cannot be listed from DNS. There is no way to ask a domain which ones it has, so the selector in the message header is the only reliable source.
The doubled hostname
Your DNS host appends the domain automatically, you typed the full name, and the key now lives at s1._domainkey.example.com.example.com.
A CNAME that leads nowhere
Many providers have you publish a CNAME to a key they host. If the CNAME is missing, mistyped, or routed through a CDN proxy instead of being served as plain DNS, the lookup fails. The Cloudflare DNS guide covers the proxy trap. Use the DNS propagation checker to see what resolvers actually return.
The key is damaged, revoked, or too small
A 2048-bit public key is roughly 400 characters of base64. A single TXT string holds 255. So the key must be stored as several quoted strings in one record:
mail2026._domainkey.example.com. TXT (
"v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv1..."
"...Xw3q9LkQIDAQAB" )Receivers join the strings with nothing in between. Trouble comes when a DNS panel silently cuts the value at 255 characters, when a stray space or line break lands inside the key, or when someone adds a second TXT record for the remainder instead of a second string. Two separate records at one selector is an error, not a longer key.
An empty p= tag is not damage. It is a statement: this key has been revoked. Providers publish it deliberately when retiring a selector. If mail is still being signed with that selector, every signature fails.
Then there is size. Keys shorter than 1024 bits are no longer accepted by receivers, and 512-bit keys have been breakable for years. 1024 is the floor; 2048 is the recommendation. If your DNS host truly cannot store a 2048-bit key, change DNS hosts before you settle for less.
The message changed after it was signed
This is the category that produces body hash did not verify, and the key is innocent. Something between the signer and the reader edited the message. Common culprits:
- An outbound gateway that appends a footer or legal disclaimer after the mail server has signed.
- A security appliance that rewrites links or strips attachments.
- A mailing list that adds a subject tag and an unsubscribe footer.
- Antivirus software that stamps “scanned and clean” at the bottom.
- A relay that re-encodes the body, converting line endings or character encoding.
For anything under your control, the principle is simple: sign last. Whatever modifies the message must do so before the signature is applied. If your gateway adds the disclaimer, your gateway should do the signing.
Canonicalization gives you some slack. The c= tag sets how strictly the message is compared. With relaxed/relaxed, changes in whitespace and header capitalization are forgiven. With simple, almost nothing is. Use relaxed for both header and body. It will not save you from an appended footer, and nothing will.
For mail altered by other people’s systems, such as mailing lists and forwarders, there is no fix on your side. Some failures of this kind are permanent background noise. They are also why a DMARC failure is not proof of spoofing.
A DKIM signature guarantees the message is unchanged. Email, as an institution, has never been able to leave a message alone.
DKIM passes and DMARC still fails
The most confusing result of all looks like this:
Authentication-Results: mx.example.net;
dkim=pass header.d=mailer-service.example;
dmarc=fail header.from=yourcompany.comThe signature is valid. It was made by your email platform, using the platform’s own domain. DMARC does not ask whether a signature passed. It asks whether a signature passed for the domain in the From line. A pass for someone else’s domain counts for nothing.
The fix is in the platform’s settings, usually called domain authentication, custom DKIM, or a verified sending domain. You publish a key or CNAMEs under your own domain, and the platform starts signing with d=yourcompany.com. The provider guides for SendGrid and Postmark show the pattern, and DMARC Alignment Explained gives the rule in full.
A message may carry more than one signature. If one of them is yours and passes, DMARC is satisfied, and the provider’s extra signature is harmless.
Three quieter mistakes
- Test mode left on. A
t=yflag in the key record tells receivers the domain is still testing DKIM. Some will discount the signature. Remove it once signing works. - The
l=tag. It signs only the first so many bytes of the body. Anything appended after that point is unsigned yet appears to be covered. It is a known weakness. Do not use it. - Expired signatures. The optional
x=tag sets an expiry time. Mail delayed in a queue past that time fails, as does any message signed by a server whose clock is wrong.
Rotation without breakage, and watching for the next failure
Keys should be rotated, and rotation is when careful setups break. The safe order: publish the new selector, confirm it resolves, switch signing to it, and leave the old key published for a week or so while mail signed with it is still in transit. Only then revoke the old one.
DKIM failures do not announce themselves. Mail keeps flowing, SPF may cover for it, and you find out when a policy change or a forwarded message exposes the gap. Aggregate reports show DKIM results per sender; Understanding DMARC Reports explains how to read them. SpoofKiller’s DKIM monitoring checks the selectors you supply, along with common provider selectors, for missing, weak, or revoked keys, and uses your reports to show whether signatures are aligning in practice.

