No Code Attached Yet J3 Issue Information Required bug
avatar dr138
dr138
20 Nov 2022

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.

Steps to reproduce the issue

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

avatar dr138 dr138 - open - 20 Nov 2022
avatar dr138 dr138 - change - 20 Nov 2022
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 20 Nov 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 20 Nov 2022
avatar ReLater
ReLater - comment - 21 Nov 2022

Joomla 3 >= 3.9.27

Is this also an issue in Joomla 4?

avatar ReLater
ReLater - comment - 21 Nov 2022

Maybe related: #32418
(Found by @ChristineWk )

avatar dr138
dr138 - comment - 21 Nov 2022

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.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39262.

avatar zero-24
zero-24 - comment - 21 Nov 2022

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.

avatar richard67 richard67 - change - 22 Nov 2022
Labels Added: J3 Issue
avatar richard67 richard67 - labeled - 22 Nov 2022
avatar brianteeman
brianteeman - comment - 20 Feb 2023

@zero-24 Surely this should be closed as there are no further fixes for j3 other than for security.

avatar Hackwar Hackwar - change - 22 Feb 2023
Labels Added: bug
avatar Hackwar Hackwar - labeled - 22 Feb 2023
avatar Quy Quy - change - 23 Feb 2023
Labels Added: Information Required
avatar Quy Quy - labeled - 23 Feb 2023
avatar Quy Quy - change - 10 Mar 2023
Status New Closed
Closed_Date 0000-00-00 00:00:00 2023-03-10 11:02:10
Closed_By Quy
avatar Quy
Quy - comment - 10 Mar 2023

Closing as Joomla 3 is now in maintenance mode and only security bugs fixes.

avatar Quy Quy - close - 10 Mar 2023

Add a Comment

Login with GitHub to post a comment