Journal's Bounce Address is not working

We are hosting multiple journals on a single OJS (3.4.0-7) installation. For each journal we have configured a separate Bounce Address (in Settings → Workflow → Email → Advanced). No matter what, the default_envelope_sender is always used as ‘Return-Path’.

I went investigating and found the following code in ./lib/pkp/classes/mail/Mailer.php on line 200. To my understanding this is the point in code that journals’ bounce address should be retrieved from database. The $data array at this point does not include the element context that is assigned to Mailable::DATA_KEY_CONTEXT, and therefore the code is skipped.

        // Set the sender provided in the context settings
        $context = $data[Mailable::DATA_KEY_CONTEXT] ?? null;
        if ($context && $sender = $context->getData('envelopeSender')) {
            $message->sender($sender);
            return;
        }

Our settings in config.inc.php are:

  • allow_envelope_sender = On
  • default_envelope_sender = bounce@address.org
  • setting force_default_envelope_sender is commented out
  • force_dmarc_compliant_from = On

Unfortunately here is where my PHP skills end and I’m no longer able to figure out what is going on. Is there a bug in code or an error in our setup?