A change to libraries/vendor/phpmailer/phpmailer/class.phpmailer.php (method mailPassthru) introduced in #33772 breaks sending of mail if phpmailer is configured to do DKIM signing (and phpmailer is configured to use php's mail()). Need also php >= 8.0 or (presumably) a windows setup (have only tested on linux + php 8.0).
The relevant patch from #33772 in libraries/vendor/phpmailer/phpmailer/class.phpmailer.php:mailPassthru()
// Joomla Backported concept from https://github.com/PHPMailer/PHPMailer/pull/2188
if (PHP_VERSION_ID >= 80000 || stripos(PHP_OS, 'WIN') === 0)
{
$header = str_replace("\n", self::CRLF, $header);
}
causes a subsequent failure if DKIM signing is done by phpmailer because phpmailer adds a "\r\n" before the dkim header, so the above patch results in this changing to "\r\r\n".
The subsequent call to mail() will fail.
Changing the str_replace line above to something like
$header = preg_replace("/(?<!\r)\n/",self::CRLF,$header);
fixes the problem.
Need php mail to be the joomla mailer and either php >= 8.0 or (presumably) windows os:
Set the joomla mailer object to do DKIM signing, eg in a system plugin onAfterInitialise():
$mailer_clone = JFactory::getMailer();
$mailer = JFactory::$mailer
$mailer->DKIM_domain = $signing_domain // eg 'example.com';
$mailer->DKIM_private = $path_to_dkim_private_key;
$mailer->DKIM_selector = $dkim_selector; // eg 'mail';
$mailer->DKIM_passphrase = '';
$mailer->DKIM_identity = $site_email_address; // eg 'website@example.com';
Any subsequent sending of mail by Joomla will fail.
Thanks, David
Labels |
Removed:
?
|
Labels |
Added:
No Code Attached Yet
|
Maybe related: #32418
(Found by @ChristineWk )
It's not an issue with J4 (which uses unpatched phpmailer).
(In sort-of answer to #32418) DKIM can be enabled with J3/J4 using eg the method I describe above. Except for J3>=3.9.27, where something like the fix I gave is needed, otherwise mail gets broken.
hmm have we verified what the plain phpmailer does in that check in newer versions? So this can be patched within our backport of the older version of phpmailer?
The first step would be a document page i'm working on for 3.10 compatibility issues with never PHP versions.
Labels |
Added:
J3 Issue
|
Labels |
Added:
bug
|
Labels |
Added:
Information Required
|
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2023-03-10 11:02:10 |
Closed_By | ⇒ | Quy |
Closing as Joomla 3 is now in maintenance mode and only security bugs fixes.
Is this also an issue in Joomla 4?