I had the same problem here with a Perl script and wrong body hash.
I used \n
for newline (example end of header line).
But you have to use \r\n
. This solved it for me!
EDIT: Thanks to ArtemGr for the comment and url to the following information (copied from http://permalink.gmane.org/gmane.mail.postfix.user/223780 to prevent link rot):
A likely cause of breakage is that the sending application generates email that is incompatible with RFC 5322 or RFC 5321 in some respect.
Lines longer than 990.
The Postfix SMTP client keeps the line length below the SMTP protocol limit of 1000 bytes including . Since this change happens after signing, it will definitely break DKIM signatures.
To avoid long-line curruption problems send mail in quoted-printable or base64 encoding, with lines of at most 80 characters long.
Malformed line endings.
SMTP requires line endings, and does not allow or characters in any other context.
The Postfix sendmail commands expects UNIX-style
<LF>
[line-feed] line endings. It will also accept lines ending in<CR><LF>
[carriage-return line-feed] but you can't use mixed line ending styles in the same message.
And so on. If you want to ensure that DKIM signatures survive, you need to send email that is within the protocol specs of RFC 5322 or RFC 5321;