From 0f2254c5ac0452c437a61476fd559549910f2381 Mon Sep 17 00:00:00 2001 From: Jack Krielen Date: Mon, 30 Dec 2019 12:12:36 +0100 Subject: [PATCH] Fix magento/magento2#6146 --- library/Zend/Mail/Transport/Sendmail.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/library/Zend/Mail/Transport/Sendmail.php b/library/Zend/Mail/Transport/Sendmail.php index 3c87aa4e8c..e04e9b2a7a 100644 --- a/library/Zend/Mail/Transport/Sendmail.php +++ b/library/Zend/Mail/Transport/Sendmail.php @@ -100,7 +100,8 @@ public function _sendMail() $this->recipients, $this->_mail->getSubject(), $this->body, - $this->header); + $this->header, + $this->_getAdditionalParameters()); restore_error_handler(); if ($this->_errstr !== null || !$result) { @@ -202,4 +203,17 @@ public function _handleMailErrors($errno, $errstr, $errfile = null, $errline = n return true; } + /** + * The additional_parameters parameter can be used to pass additional flags as command line options to the program + * configured to be used when sending mail, as defined by the sendmail_path configuration setting. + * For example, this can be used to set the envelope sender address when using sendmail with the -f sendmail option. + * + * @return null|string + */ + protected function _getAdditionalParameters() { + if (!empty($this->_mail->getReturnPath())) { + return '-f ' . $this->_mail->getReturnPath(); + } + return null; + } }