About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
When a DKIM check ends in "PERMFAIL (body hash did not verify)", the signature's bh= value is not the hash of the body the receiver has. RFC 6376 says the verifier compares that hash with bh= and, if it does not match, "the Verifier SHOULD ignore the signature and return PERMFAIL (body hash did not verify)." Something altered the body after it was signed, or the signer hashed a different body from the one that was sent.
A different result, "PERMFAIL (signature did not verify)", is the check of the b= header signature, not the body hash. Fix the body mismatch before chasing the public key.
What the symptom means
bh= is "The hash of the canonicalized body part of the message as limited by the "l=" tag". The signer and the verifier both hash the body after the body canonicalization named in c=, then cut it to the length in l= if that tag is present. That hash is what bh= holds. Canonicalization prepares the copy that is hashed. RFC 6376 says it "does not affect the transmitted email in any way."
c= defaults to simple/simple. The part after the slash is the body algorithm. c=relaxed means relaxed headers and a simple body.
The simple body algorithm "ignores all empty lines at the end of the message body" and "makes no other changes to the message body." If there is no body or no trailing CRLF, a CRLF is added. An empty body becomes one CRLF. A changed word, an added footer or a changed line ending inside the body fails this hash.
The relaxed body algorithm reduces whitespace and then drops empty lines at the end. It ignores whitespace at the end of lines, and it reduces each run of whitespace inside a line to a single space. It does not ignore a changed word or an added line of text.
l= limits how many octets of that canonicalized body are hashed. "All data beyond that limit is not validated by DKIM." A verifier "can choose to treat the signature as if it were invalid" and return "PERMFAIL (unsigned content)". RFC 6376 also says "The use of "l=0" takes this to the extreme, allowing complete alteration of the text of the message without invalidating the signature."
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
| A footer, disclaimer or list trailer was added after signing | PERMFAIL (body hash did not verify) on mail that left a gateway or a list | Compare the signed body with the body in the received message |
| The signer hashed a local copy, then the outgoing copy changed line endings | PERMFAIL (body hash did not verify) although no gateway added text | Compare the line endings (CRLF or bare LF) of the copy that was signed and the copy that was sent. RFC 6376 says bare CR or LF characters MUST be converted to CRLF before the message is signed, and that this conversion SHOULD be applied to the message actually sent to the recipients, not just to the version given to the signing algorithm |
| Relaxed canonicalization was expected to forgive a wording change | The hash still fails | Relaxed body canonicalization reduces whitespace and drops empty lines at the end of the body, and nothing else |
l= is present and the verifier rejects unsigned tail content |
PERMFAIL (unsigned content), or a body-hash failure if the prefix itself changed | Read l= on the DKIM-Signature header |
Prove the cause before changing anything
All of these are read-only.
1. Read the signature on a failing message. Find c=, l= if it is present, and bh=. The default canonicalization is simple/simple when c= is absent. A body failure is the bh= check. A b= failure is a different PERMFAIL.
2. Compare the body that was signed with the body that arrived. Under simple body canonicalization, only the trailing empty lines are ignored. Any other difference fails the hash. Under relaxed, ignore end-of-line whitespace and collapsed spaces inside lines, then compare. A new last paragraph is still a change.
3. See whether l= left a tail unsigned. If l= is set, octets past that count are not covered. The failure may be the verifier refusing that tail, which RFC 6376 allows, rather than a mismatch of the hashed prefix.
Fix
The signer "MUST sign the message as it is expected to be received by the Verifier rather than in some local or internal form." Put every body change on the copy that is hashed, and stop changing the body after that.
Stop rewriting the body after the signature
Save the DKIM-Signature header of a failing message with this command, where failing-message.eml is the saved raw message, and paste the text of the current footer or rewrite rule from your gateway or list settings into a second file named footer-rule-before.txt:
grep -i -A4 '^DKIM-Signature:' failing-message.eml > dkim-signature-before.txt
Risk: the next step moves or removes the footer or rewrite rule, so mail then leaves without it where it is applied now. A legal line or a list instruction that you remove will be absent until you put it back.
Move the footer or rewrite so that it is applied to the message before signing, or remove it from the path after the signature. Sign that final body. RFC 6376 says "it is very common for mailing lists to add trailers to messages", and it says the l= tag "enables attacks in which an intermediary with malicious intent can modify a message". Prefer signing the finished body over publishing l=.
To undo it, put the text saved in footer-rule-before.txt back where it was applied before, and send the next message through the same path you used before the change.
Example (illustrative): news.example.com signs with simple body canonicalization, then a gateway appends "Unsubscribe at https://news.example.com/leave". Receivers report PERMFAIL (body hash did not verify). The administrator saves the footer text, removes it from the post-signature step, and appends the same sentence in the composition step that runs before signing. The next test message verifies. Putting the saved footer back after the signer reproduces the failure.
Confirm the fix
- Send a new message through the same path. On a receiver that shows the result, the body-hash PERMFAIL is gone.
- Confirm the body that arrived is the body you hashed. A later gateway that still adds a line will fail the new signature too.
- Repeat for each system that signs or rewrites mail for the domain.
What to watch afterwards
- A new disclaimer, archive footer or security gateway can be inserted after the signer. Check a message after every such change.
- Keep
l=off unless you have a reason that matches the mailing-list case in RFC 6376, and expect some verifiers to reject a shortl=. - Header changes are the
b=check. A body-hash pass does not prove the header signature.
Read next
Related articles you may want next.
- HostingApplication Email Rejected or Junked After a Server Move: SPF, DKIM, DMARC and PTRApplication mail bouncing or junked after a migration? Read Authentication-Results, then fix SPF, DKIM, DMARC alignment, PTR and Microsoft 365 relay settings for the new path.Read article
- TroubleshootingDMARC fail: what p=none, quarantine and reject ask a receiver to doAuthentication shows dmarc fail. RFC 7489 defines that result, and p=none, quarantine or reject as the policy. Read the TXT record before you change it.Read article
- TroubleshootingSPF permerror: too many DNS lookups. Count the limit of 10, then shorten the record safelySPF permerror because the record needs more than 10 DNS lookups. Count the terms that query DNS, find the extra ones and shorten the record safely.Read article
Risks and limits
- The PERMFAIL strings are the ones RFC 6376 tells a verifier to return. A receiver may wrap them in its own text.
- Relaxed body canonicalization does not make a wording change verify.
- DKIM does not by itself decide delivery. SPF, DMARC and reputation are separate checks.
Sources
- RFC 6376: DomainKeys Identified Mail (DKIM) Signatures — IETF, September 2011, accessed 22 November 2026
This article was originally published on .