Php – DKIM body hash fail

dkimeximPHP

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=;
    b=ILyB0JLZLWTig346yGWzmOwk+bEgr0k3hjYyPovA4B3+ggRshzTX9yDeAeklEmYaq4H768zZc0Vn6tR9YpngllkHJ6XTf3lTPr570yWOEhE8dvCkq+M0CBXmxEApHJmoKq2Oeh7sFCHVWGiN8JXYa8ohgsSFEd5Z+xHFlj3AvbI=;

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?

Best Answer

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]
[LF]
[LF]
<?php echo $content_for_layout; ?> [LF]

But this works as it should

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

Not the space before the last [LF].