Answer the question
In order to leave comments, you need to log in
Why emails sent by PHPMailer fail DKIM check?
I connected DKIM on my hosting to sign sent letters.
The DKIM signature is added on the SMTP server.
I check the validity of the DKIM signature using the www.brandonchecketts.com/emailtest.php
service.
When sending via the web mail interface and via the desktop client, the validation passes.
When sending using a PHP script using PHPMailer, validation fails.
At the same time, when sending using a PHP script that uses SwiftMailer, validation passes.
What could be the problem?
Answer the question
In order to leave comments, you need to log in
Actually, judging by the headers, instead of DKIM (RFC 4871) you have the outdated DomainKeys (RFC 4870), DKIM uses DKIM-Signature, not DomainKey-Signature. According to RFC 4870, hardly anyone will help you, because in practice it has never been much used. Apparently, somewhere something is not screwed.
Added DKIM instead of Domain Keys and made the following changes to PHPMailer
Line 2282:
change
$headers = explode("\n\r",$headers_line);
to
$headers = explode($this->LE,$headers_line);
Lines 2292 and 2293
change
$from = str_replace('|','=7C',$this->DKIM_QP($from_header));
$to = str_replace('|','=7C',$this->DKIM_QP($to_header));
to
$from = str_replace('|','=7C',($from_header));
$to = str_replace('|','=7C',($to_header));
Line 2297
change
$DKIMb64 = base64_encode(pack("H*", sha1($body))) ;
to
$DKIMb64 = base64_encode(pack("H*", sha1("\r\n" . preg_replace("/\r\n$/", "", $body)))) ;
After that everything worked :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question