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) {
public function mail(array $message) {
// If 'Return-Path' isn't already set in php.ini, we pass it separately
// 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']) && !ini_get('safe_mode')) {
if (isset($message['headers']['Return-Path'])) {
$return_path_set = strpos(ini_get('sendmail_path'), ' -f');
if (!$return_path_set) {
$message['Return-Path'] = $message['headers']['Return-Path'];
......@@ -85,29 +84,17 @@ public function mail(array $message) {
// hosts. The return value of this method will still indicate whether mail
// was sent successfully.
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
// is used to set the Return-Path. There is no space between -f and
// the value of the return path.
$mail_result = @mail(
$message['to'],
$mail_subject,
$mail_body,
$mail_headers,
'-f' . $message['Return-Path']
);
}
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
);
}
// 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
// the value of the return path.
$additional_headers = isset($message['Return-Path']) ? '-f' . $message['Return-Path'] : '';
$mail_result = @mail(
$message['to'],
$mail_subject,
$mail_body,
$mail_headers,
$additional_headers
);
}
else {
// On Windows, PHP will use the value of sendmail_from for the
......
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