Skip to content
Browse files

Ensure that setting Return-Path always overrides the envelope sender.

git-svn-id: http://svn.php.net/repository/pear/packages/Mail/trunk@239266 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent ad63717 commit 37719facf2191f3f4c2c667bb6cad9cf7e4a13b0 Chuck Hagenbuch committed
Showing with 24 additions and 21 deletions.
  1. +2 −1 Mail.php
  2. +10 −16 Mail/mail.php
  3. +11 −4 Mail/sendmail.php
  4. +1 −0 package.xml
View
3 Mail.php
@@ -82,6 +82,7 @@ function &factory($driver, $params = array())
* @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on
* failure.
+ *
* @access public
* @deprecated use Mail_mail::send instead
*/
@@ -103,7 +104,7 @@ function send($recipients, $headers, $body)
}
// flatten the headers out.
- list(,$text_headers) = Mail::prepareHeaders($headers);
+ list(, $text_headers) = Mail::prepareHeaders($headers);
return mail($recipients, $subject, $body, $text_headers);
View
26 Mail/mail.php
@@ -41,9 +41,9 @@ class Mail_mail extends Mail {
*/
function Mail_mail($params = null)
{
- /* The other mail implementations accept parameters as arrays.
- * In the interest of being consistent, explode an array into
- * a string of parameter arguments. */
+ // The other mail implementations accept parameters as arrays.
+ // In the interest of being consistent, explode an array into
+ // a string of parameter arguments.
if (is_array($params)) {
$this->_params = join(' ', $params);
} else {
@@ -61,7 +61,7 @@ function Mail_mail($params = null)
}
}
- /**
+ /**
* Implements Mail_mail::send() function using php's built-in mail()
* command.
*
@@ -104,10 +104,8 @@ function send($recipients, $headers, $body)
unset($headers['Subject']);
}
- /*
- * Also remove the To: header. The mail() function will add its own
- * To: header based on the contents of $recipients.
- */
+ // Also remove the To: header. The mail() function will add its own
+ // To: header based on the contents of $recipients.
unset($headers['To']);
// Flatten the headers out.
@@ -117,10 +115,8 @@ function send($recipients, $headers, $body)
}
list(, $text_headers) = $headerElements;
- /*
- * We only use mail()'s optional fifth parameter if the additional
- * parameters have been provided and we're not running in safe mode.
- */
+ // We only use mail()'s optional fifth parameter if the additional
+ // parameters have been provided and we're not running in safe mode.
if (empty($this->_params) || ini_get('safe_mode')) {
$result = mail($recipients, $subject, $body, $text_headers);
} else {
@@ -128,10 +124,8 @@ function send($recipients, $headers, $body)
$this->_params);
}
- /*
- * If the mail() function returned failure, we need to create a
- * PEAR_Error object and return it instead of the boolean result.
- */
+ // If the mail() function returned failure, we need to create a
+ // PEAR_Error object and return it instead of the boolean result.
if ($result === false) {
$result = PEAR::raiseError('mail() returned failure');
}
View
15 Mail/sendmail.php
@@ -24,21 +24,21 @@
*/
class Mail_sendmail extends Mail {
- /**
+ /**
* The location of the sendmail or sendmail wrapper binary on the
* filesystem.
* @var string
*/
var $sendmail_path = '/usr/sbin/sendmail';
- /**
+ /**
* Any extra command-line parameters to pass to the sendmail or
* sendmail wrapper binary.
* @var string
*/
var $sendmail_args = '-i';
- /**
+ /**
* Constructor.
*
* Instantiates a new Mail_sendmail:: object based on the parameters
@@ -77,7 +77,7 @@ function Mail_sendmail($params)
}
}
- /**
+ /**
* Implements Mail::send() function using the sendmail
* command-line binary.
*
@@ -117,6 +117,13 @@ function send($recipients, $headers, $body)
}
list($from, $text_headers) = $headerElements;
+ /* Since few MTAs are going to allow this header to be forged
+ * unless it's in the MAIL FROM: exchange, we'll use
+ * Return-Path instead of From: if it's set. */
+ if (!empty($headers['Return-Path'])) {
+ $from = $headers['Return-Path'];
+ }
+
if (!isset($from)) {
return PEAR::raiseError('No from address given.');
} elseif (strpos($from, ' ') !== false ||
View
1 package.xml
@@ -32,6 +32,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
</stability>
<license>PHP/BSD</license>
<notes>- Allow turning on SMTP pipelining if the SMTP server and Net_SMTP support it.
+- Ensure that setting Return-Path always overrides the envelope sender.
</notes>
<contents>
<dir name="/">

0 comments on commit 37719fa

Please sign in to comment.
Something went wrong with that request. Please try again.