Include the last error if available when sending with mail() fails.

When sending email using mail() include the last error if available.

Fixes #2910
This commit is contained in:
mark_story 2014-03-02 21:07:25 -05:00
parent e89081a3ce
commit 549908738b

View file

@ -67,11 +67,15 @@ class MailTransport extends AbstractTransport {
if (ini_get('safe_mode')) {
//@codingStandardsIgnoreStart
if (!@mail($to, $subject, $message, $headers)) {
throw new SocketException(__d('cake_dev', 'Could not send email.'));
$error = error_get_last();
$msg = 'Could not send email: ' . isset($error['message']) ? $error['message'] : 'unknown';
throw new SocketException($msg);
}
} elseif (!@mail($to, $subject, $message, $headers, $params)) {
$error = error_get_last();
$msg = 'Could not send email: ' . isset($error['message']) ? $error['message'] : 'unknown';
//@codingStandardsIgnoreEnd
throw new SocketException(__d('cake_dev', 'Could not send email.'));
throw new SocketException($msg);
}
}