I have recently updated to 2.2.4 and made a few minor changes however have just noticed that order emails are now sending with the wrong from address and is not set as per settings in
Store -> Configuration -> General -> Store Email Addresses as I believe normally sets this.
Header shows like below:
From: Apache <email@example.com> Return-Path: firstname.lastname@example.org
However previous headers and the current live site set this correctly and am unsure why this has suddenly started. Emails sent from forgotten passwords works fine and from what I can tell this is only effecting the order and shipment emails.
I have tried debugged this through about a maze of files all the way down to
Magento\Framework\Mail\Template\TransportBuilderByStore and everything seems fine back to there.
$this->message->setFrom($result['email'], $result['name']); seems to be correct and
$result['name'] are correct at this stage however the from address is not set.
$this->message uses the
magento\Framework\Mail\Message class which just extends
Zend_Mail for the setting of the from address so am unsure what could go wrong at this stage considering the variables sent to the function look fine.
Forgotten password however does not seem to use the TransportBuilderByStore so will try and figure out what is different for forgotten password emails.
I can see a similar issue here: https://github.com/magento/magento2/issues/6146 however this is very old. Has anyone else had an issue with this recently since updating? Why would this go wrong and how can I fix?
For now my best bet is just setting the from address via vhosts for each of the multi stores like below however would like to find out why this is happening?
php_admin_value sendmail_path "/usr/sbin/sendmail -email@example.com -F 'Sales Department <firstname.lastname@example.org>' -t