Fix DKIM's error when there is S/MIME-sign

This commit is contained in:
Nguyen Anh Tu 2021-05-17 16:13:19 +07:00
parent 4839207650
commit 5727f73007
1 changed files with 8 additions and 1 deletions

View File

@ -2933,7 +2933,14 @@ class PHPMailer
@unlink($signed);
//The message returned by openssl contains both headers and body, so need to split them up
$parts = explode("\n\n", $body, 2);
$this->MIMEHeader .= $parts[0] . static::$LE . static::$LE;
//In $parts[0] there is MIME-Version and Content-Type delimited by "\n".
//Need to separate them, otherwise error with DKIM: "dkim=neutral (body hash did not verify)"
//(The reason is in "h=Date:To:From:Reply-To:Subject:Message-ID:X-Mailer;" without MIME-Version and Content-Type)
$subparts = array_map('trim', explode("\n", $parts[0]));
foreach($subparts as $subpart) {
$this->MIMEHeader .= $subpart . static::$LE;
}
$this->MIMEHeader .= static::$LE;
$body = $parts[1];
} else {
@unlink($signed);