Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DKIM fails when I use version >= 6 #1823

Closed
heminei opened this issue Aug 30, 2019 · 2 comments
Closed

DKIM fails when I use version >= 6 #1823

heminei opened this issue Aug 30, 2019 · 2 comments

Comments

@heminei
Copy link

heminei commented Aug 30, 2019

Hi,
When I update PHPMailer from version 5.2.27 to 6.0.7 DKIM stop working. When reverting to v5.2.27 DKIM works properly.

Sample code:

$mail = new \PHPMailer();
$mail->isHTML();
$mail->CharSet = "UTF-8";
$mail->DKIM_domain = 'example.net';
$mail->DKIM_private = '.htkeyprivate';
$mail->DKIM_selector = 'phpmailer';
$mail->DKIM_identity = "test@example.com";
$mail->DKIM_passphrase = '';

$mail->setFrom("test@example.com", "Test test");
$mail->addAddress("test2@example.com", "test2 test");
$mail->Subject = "Test test";
$mail->msgHTML("Test html html");
$mail->send()

The DKIM key is generated with DKIM_gen_keys.phps.

Thanks :)

@bartkaandorp
Copy link

I had the same issue.

It looks like the issue comes from the removing of spaces from $dkimhdrs. That variable is set with "\r\n ", but in DKIM_HeaderC this is removed by preg_replace('/\r\n[ \t]+/m', '', $signHeader)

Because of that there is no space between some of the values in the DKIM signature, so the output hash is not valid.

It is fixed by removing the "\r\n" in the $dkimhdrs or changing line 4357 in src/PHPMailer.php:
$signHeader = preg_replace('/\r\n[ \t]+/m', '', $signHeader);
$signHeader = preg_replace('/\r\n[ \t]+/m', ' ', $signHeader);

@Synchro
Copy link
Member

Synchro commented Sep 12, 2019

That is not an appropriate fix because it causes problems elsewhere, discussed in #1525.

@Synchro Synchro closed this as completed Sep 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants