From 7d341c105b694bbf772a99974b0e301bbfe98de2 Mon Sep 17 00:00:00 2001 From: Marcus Bointon Date: Mon, 6 Jun 2016 10:36:56 +0200 Subject: [PATCH] Don't set mail() additional_parameters to space when not being used, fixes #582 --- class.phpmailer.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/class.phpmailer.php b/class.phpmailer.php index 14842160..9782709b 100644 --- a/class.phpmailer.php +++ b/class.phpmailer.php @@ -681,7 +681,9 @@ class PHPMailer } else { $subject = $this->encodeHeader($this->secureHeader($subject)); } - if (ini_get('safe_mode') || !($this->UseSendmailOptions)) { + //Can't use additional_parameters in safe_mode + //@link http://php.net/manual/en/function.mail.php + if (ini_get('safe_mode') or !$this->UseSendmailOptions) { $result = @mail($to, $subject, $body, $header); } else { $result = @mail($to, $subject, $body, $header, $params); @@ -1425,9 +1427,9 @@ class PHPMailer } $to = implode(', ', $toArr); - if (empty($this->Sender)) { - $params = ' '; - } else { + $params = null; + //This sets the SMTP envelope sender which gets turned into a return-path header by the receiver + if (!empty($this->Sender)) { $params = sprintf('-f%s', $this->Sender); } if ($this->Sender != '' and !ini_get('safe_mode')) { @@ -1435,7 +1437,7 @@ class PHPMailer ini_set('sendmail_from', $this->Sender); } $result = false; - if ($this->SingleTo && count($toArr) > 1) { + if ($this->SingleTo and count($toArr) > 1) { foreach ($toArr as $toAddr) { $result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params); $this->doCallback($result, array($toAddr), $this->cc, $this->bcc, $this->Subject, $body, $this->From);