diff --git modules/system/system.mail.inc modules/system/system.mail.inc index 14ba64f..e3727b8 100644 --- modules/system/system.mail.inc +++ modules/system/system.mail.inc @@ -67,7 +67,11 @@ class DefaultMailSystem implements MailSystemInterface { // but some MTAs incorrectly replace LF with CRLF. See #234403. $mail_headers = join("\n", $mimeheaders); if (isset($message['Return-Path']) && !ini_get('safe_mode')) { - $mail_result = mail( + $old_from = ini_get('sendmail_from'); + // On Windows PHP will use the value of sendmail_from for the Return-Path + // header. + ini_set('sendmail_from', $message['Return-Path']); + $mail_result = @mail( $message['to'], $mail_subject, $mail_body, @@ -75,12 +79,17 @@ class DefaultMailSystem implements MailSystemInterface { // Pass the Return-Path via sendmail's -f command. '-f ' . $message['Return-Path'] ); + + if (!empty($old_from)) { + // Set sendmail_from back to its previous value. + ini_set('sendmail_from', $old_from); + } } else { // The optional $additional_parameters argument to mail() is not allowed // if safe_mode is enabled. Passing any value throws a PHP warning and // makes mail() return FALSE. - $mail_result = mail( + $mail_result = @mail( $message['to'], $mail_subject, $mail_body,