diff --git a/lib/Cake/Network/Email/MailTransport.php b/lib/Cake/Network/Email/MailTransport.php index a037e3418..950459a75 100644 --- a/lib/Cake/Network/Email/MailTransport.php +++ b/lib/Cake/Network/Email/MailTransport.php @@ -42,11 +42,7 @@ class MailTransport extends AbstractTransport { $headers = $this->_headersToString($headers, $eol); $message = implode($eol, $email->message()); - $params = null; - if (!ini_get('safe_mode')) { - $params = isset($this->_config['additionalParameters']) ? $this->_config['additionalParameters'] : null; - } - + $params = isset($this->_config['additionalParameters']) ? $this->_config['additionalParameters'] : null; $this->_mail($to, $email->subject(), $message, $headers, $params); return array('headers' => $headers, 'message' => $message); } @@ -58,16 +54,20 @@ class MailTransport extends AbstractTransport { * @param string $subject email's subject * @param string $message email's body * @param string $headers email's custom headers - * @param string $params additional params for sending email + * @param string $params additional params for sending email, will be ignored when in safe_mode * @throws SocketException if mail could not be sent * @return void */ protected function _mail($to, $subject, $message, $headers, $params = null) { - //@codingStandardsIgnoreStart - if (!@mail($to, $subject, $message, $headers, $params)) { + if (ini_get('safe_mode')) { + //@codingStandardsIgnoreStart + if (!@mail($to, $subject, $message, $headers)) { + throw new SocketException(__d('cake_dev', 'Could not send email.')); + } + } elseif (!@mail($to, $subject, $message, $headers, $params)) { + //@codingStandardsIgnoreEnd throw new SocketException(__d('cake_dev', 'Could not send email.')); } - //@codingStandardsIgnoreEnd } }