DKIM fail: "body hash did not verify"

The message was changed after it was signed. Footers, disclaimers, gateways and mailing lists are the usual suspects.

dkim=fail (body hash did not verify) header.d=example.com
dkim=neutral (body hash did not verify)

A DKIM signature includes a hash of the message body. The receiver computed the hash again and got a different result: the body was changed after the message was signed. Even one added space or line break is enough.

What changes the body

  • Mailing lists that add a footer ("You received this because…") or rewrite the subject. See mailing lists and forwarding.
  • Email security gateways and antivirus that rewrite links, add a banner like "External sender", or strip attachments.
  • Signature and disclaimer tools that add a company signature on the way out, after your mail provider already signed the message.
  • Your own server signing too early. If DKIM signing happens before another step that edits the message (a content filter, a relay that converts encodings), the signature breaks every time.
  • Line-ending or encoding changes by a relay: converting 8-bit to quoted-printable, or long lines being wrapped.

How to fix it

  1. Compare where the message was signed with the hops listed in its Received: headers. The culprit sits between the signer and the receiver.
  2. Make DKIM signing the last step before mail leaves your organisation. Signature and disclaimer tools should run before signing, or sign themselves.
  3. Use relaxed/relaxed canonicalization (c=relaxed/relaxed in the signature). It tolerates whitespace changes. Most providers use it by default.
  4. If the change happens at the recipient's side (their gateway or a mailing list), you can't fix it at your end. Receivers that support ARC may still accept the message.