Make envelope sender config work the same way for `mail()`` as it does for SMTP, preferring `Sender` over `sendmail_from` ini setting.

This commit is contained in:
Marcus Bointon 2021-02-05 09:59:54 +01:00
parent 2eaa82698d
commit f9f5b8d21e
No known key found for this signature in database
GPG Key ID: DE31CD6EB646AA24
1 changed files with 9 additions and 2 deletions

View File

@ -1813,10 +1813,17 @@ class PHPMailer
//Qmail docs: http://www.qmail.org/man/man8/qmail-inject.html
//Example problem: https://www.drupal.org/node/1057954
// CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped.
if (!empty($this->Sender) && static::validateAddress($this->Sender) && self::isShellSafe($this->Sender)) {
$params = sprintf('-f%s', $this->Sender);
if ('' === $this->Sender) {
$this->Sender = $this->From;
}
if (empty($this->Sender) && !empty(ini_get('sendmail_from'))) {
//PHP config has a sender address we can use
$this->Sender = ini_get('sendmail_from');
}
if (!empty($this->Sender) && static::validateAddress($this->Sender)) {
if (self::isShellSafe($this->Sender)) {
$params = sprintf('-f%s', $this->Sender);
}
$old_from = ini_get('sendmail_from');
ini_set('sendmail_from', $this->Sender);
}