A lot of debugging went in to this, but I eventually managed to trace the issue back to the mimemail_rfc_headers function of Mime Mail.

Basically Mimemail creates headers like this:

From:foo@bar.com
To:bar@foo.com

By logging the temp files of OpenDKIM, I could see it was using the headers in the format shown in the RFC 822 examples, like this:

From: foo@bar.com
To: bar@foo.com

This meant that the DKIM signature for the mail is created with the space, but the mail is delivered without a space so when the headers are hashed by the client, DKIM fails.

I haven't been able to create a patch for this, but I did the following, to make Mime Mail output headers as per the RFC examples and DKIM then passes without issue.

In "/mimemail.inc", Line 40, change:

From this:
$header .= $key . ":" . $value . $crlf;

To this:
$header .= $key . ": " . $value . $crlf;

Comments

sgabe’s picture

Status: Active » Fixed

I think both format should be fine, since the separator character is the colon.

  • sgabe committed 9f8a6d5 on 7.x-1.x
    Issue #2404719: Missing space in RFC headers breaks DKIM
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.