mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
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:
parent
e89081a3ce
commit
549908738b
1 changed files with 6 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue