note 126740 deleted from function.mail by crell
| From: | crell@php.net | Date: | Tue, 12 Apr 2022 01:09:48 +0000 |
| Subject: | note 126740 deleted from function.mail by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218232@lists.php.net to get a copy of this message | ||
Note Submitter: mycplus at NOSPAM dot gmail dot com
----
Throw the exception if the message was not delivered. It allows you to distinguish and route the
error messages to a specific class for handling.
<?php
function SendEmail($to, $subject, $message, $headers, $params = null) {
if (!@mail($to, $subject, $message, $headers, $params)) {
$error = error_get_last();
$msg = 'Could not send email: ' . (isset($error['message']) ?
$error['message'] : 'unknown');
throw new SocketException($msg);
}
}
?>