Commit b1b69f72 authored by webchick's avatar webchick

Issue #2207021 by Berdir: Remove legacy PHP 5.3 code from PhpMail plugin.

parent 7d985d59
...@@ -55,8 +55,7 @@ public function format(array $message) { ...@@ -55,8 +55,7 @@ public function format(array $message) {
public function mail(array $message) { public function mail(array $message) {
// If 'Return-Path' isn't already set in php.ini, we pass it separately // If 'Return-Path' isn't already set in php.ini, we pass it separately
// as an additional parameter instead of in the header. // as an additional parameter instead of in the header.
// However, if PHP's 'safe_mode' is on, this is not allowed. if (isset($message['headers']['Return-Path'])) {
if (isset($message['headers']['Return-Path']) && !ini_get('safe_mode')) {
$return_path_set = strpos(ini_get('sendmail_path'), ' -f'); $return_path_set = strpos(ini_get('sendmail_path'), ' -f');
if (!$return_path_set) { if (!$return_path_set) {
$message['Return-Path'] = $message['headers']['Return-Path']; $message['Return-Path'] = $message['headers']['Return-Path'];
...@@ -85,30 +84,18 @@ public function mail(array $message) { ...@@ -85,30 +84,18 @@ public function mail(array $message) {
// hosts. The return value of this method will still indicate whether mail // hosts. The return value of this method will still indicate whether mail
// was sent successfully. // was sent successfully.
if (!$request->server->has('WINDIR') && strpos($request->server->get('SERVER_SOFTWARE'), 'Win32') === FALSE) { if (!$request->server->has('WINDIR') && strpos($request->server->get('SERVER_SOFTWARE'), 'Win32') === FALSE) {
if (isset($message['Return-Path']) && !ini_get('safe_mode')) {
// On most non-Windows systems, the "-f" option to the sendmail command // On most non-Windows systems, the "-f" option to the sendmail command
// is used to set the Return-Path. There is no space between -f and // is used to set the Return-Path. There is no space between -f and
// the value of the return path. // the value of the return path.
$additional_headers = isset($message['Return-Path']) ? '-f' . $message['Return-Path'] : '';
$mail_result = @mail( $mail_result = @mail(
$message['to'], $message['to'],
$mail_subject, $mail_subject,
$mail_body, $mail_body,
$mail_headers, $mail_headers,
'-f' . $message['Return-Path'] $additional_headers
); );
} }
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(
$message['to'],
$mail_subject,
$mail_body,
$mail_headers
);
}
}
else { else {
// On Windows, PHP will use the value of sendmail_from for the // On Windows, PHP will use the value of sendmail_from for the
// Return-Path header. // Return-Path header.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment