We're sending out e-mails with EXIM 4.71 from a PHP application. DKIM is enabled and is working properly, unless when sending a specific type of mails, which results in dkim=neutral (body hash did not verify).

Received-SPF: pass (google.com: domain of no-reply@letsrace.se designates 2a02:750:5::256 as permitted sender) client-ip=2a02:750:5::256;
Authentication-Results: mx.google.com;
       spf=pass (google.com: domain of no-reply@letsrace.se designates 2a02:750:5::256 as permitted sender) smtp.mail=no-reply@letsrace.se;
       dkim=neutral (body hash did not verify) header.i=@letsrace.se
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=letsrace.se; s=dkim;
    h=Content-Transfer-Encoding:Content-Type:Reply-To:From:Subject:To:Message-Id:Date; bh=9CkFmpgBio6ql+M36DtO8Gbw8keno3PlJ6db2JTrwy4=;

The type of e-mail which fails contains a message entered via a HTML form on the site, and other mails sent from this application are fine. I have been suspecting mixed line endings to be the culprit, but haven't been able to improve the situation by normalizing line endings.

Is EXIM performing some cleanup after it creates the DKIM hash?

Any ideas?

  • What are you using to send the mail? – Michael Hampton Mar 6 '13 at 12:22
  • PHP mail() -> local EXIM, or what did you mean? – Oscar Mar 6 '13 at 12:31
  • This does seems like a white space/EOL issue. If I switch to my default layout for the mails being sent, it works. The only difference (apart from some greetings) is that there is no extra LF after the message. – Oscar Mar 6 '13 at 12:58
  • I'm told that the latest Exim update addresses and fixes this problem - released mid December 2015. – user331600 Jan 13 '16 at 5:19

This was very odd, but the following seems to be true:

This does not work, resulting in DKIM body hash fail

<?php echo $heading; ?> [LF]
<?php echo $content_for_layout; ?> [LF]

But this works as it should

<?php echo $heading; ?> [LF]
<?php echo $content_for_layout; ?>[LF]

Not the space before the last [LF].

  • DKIM also fails the same way now if $content_for_layout ends with newlines, but that should be easily fixed with trim(). – Oscar Mar 6 '13 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.