DKIM "body hash did not verify"

The message body changed after it was signed.

DKIM keys, selectors and key length.

What the error means

A DKIM signature contains a hash of the message body (bh=). When the receiver computes the hash of the body it got and it does not match, the signature fails with "body hash did not verify". In short: the body changed between signing and delivery. The key in DNS is fine; otherwise the error would be different ("signature did not verify" or "no key").

What changes the body

CauseTypical case
A footer added after signingMailing lists, antivirus disclaimers, "Sent from my…" added by a gateway.
Forwarding and listsGoogle Groups, Mailman or a forwarder rewriting the message.
Signing too earlyThe app signs, then a relay re-encodes the message (quoted-printable, base64) or wraps lines.
Line endings or whitespaceScripts sending LF instead of CRLF, or trailing spaces, with c=simple canonicalization.

How to fix it

  1. Sign last: DKIM must be added by the final server that sends to the internet, after any footer or disclaimer.
  2. Use relaxed canonicalization (c=relaxed/relaxed): it tolerates whitespace and line wrapping changes.
  3. For mailing lists, the list should sign with its own domain; ARC helps receivers trust forwarded mail.
  4. Check that the key published in DNS is the one being used, with the DKIM checker above, and test again with a fresh message.

If DKIM fails and SPF is not aligned, the message also gets dmarc=fail. The email header analyzer shows the results of a real message.

Related errors

Last updated: