do not pass 5th argument to mail() when in safe mode, even with a falsy value mail() will return false, fixes #3452

This commit is contained in:
Ceeram 2012-12-13 18:16:30 +01:00
parent 45f6ade800
commit 53b465d64e

View file

@ -42,11 +42,7 @@ class MailTransport extends AbstractTransport {
$headers = $this->_headersToString($headers, $eol); $headers = $this->_headersToString($headers, $eol);
$message = implode($eol, $email->message()); $message = implode($eol, $email->message());
$params = null; $params = isset($this->_config['additionalParameters']) ? $this->_config['additionalParameters'] : null;
if (!ini_get('safe_mode')) {
$params = isset($this->_config['additionalParameters']) ? $this->_config['additionalParameters'] : null;
}
$this->_mail($to, $email->subject(), $message, $headers, $params); $this->_mail($to, $email->subject(), $message, $headers, $params);
return array('headers' => $headers, 'message' => $message); return array('headers' => $headers, 'message' => $message);
} }
@ -58,16 +54,20 @@ class MailTransport extends AbstractTransport {
* @param string $subject email's subject * @param string $subject email's subject
* @param string $message email's body * @param string $message email's body
* @param string $headers email's custom headers * @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 * @throws SocketException if mail could not be sent
* @return void * @return void
*/ */
protected function _mail($to, $subject, $message, $headers, $params = null) { protected function _mail($to, $subject, $message, $headers, $params = null) {
//@codingStandardsIgnoreStart if (ini_get('safe_mode')) {
if (!@mail($to, $subject, $message, $headers, $params)) { //@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.')); throw new SocketException(__d('cake_dev', 'Could not send email.'));
} }
//@codingStandardsIgnoreEnd
} }
} }