Skip to content

Commit

Permalink
Make envelope sender config work the same way for mail()` as it doe…
Browse files Browse the repository at this point in the history
…s for SMTP, preferring `Sender` over `sendmail_from` ini setting.
  • Loading branch information
Synchro committed Feb 5, 2021
1 parent 2eaa826 commit f9f5b8d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/PHPMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1813,10 +1813,17 @@ protected function mailSend($header, $body)
//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);
}
Expand Down

0 comments on commit f9f5b8d

Please sign in to comment.