note 126706 added to function.mail
| From: | Saqib at main dot php dot net | Date: | Thu, 23 Dec 2021 14:47:09 +0000 |
| Subject: | note 126706 added to function.mail | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-217407@lists.php.net to get a copy of this message | ||
Further to https://www.php.net/manual/en/function.mail.php#121163,
sometime it's helpful to throw Exceptions to distinguish between different types of errors, and
is also great for routing.
<?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);
}
}
?>
Thanks to https://www.mycplus.com/source-code/php/send-email-using-php/
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.135 (proxied: 206.84.136.54)
----
Manual Page -- https://php.net/manual/en/function.mail.php
Edit -- https://main.php.net/note/edit/126706
Del: integrated -- https://main.php.net/note/delete/126706/integrated
Del: useless -- https://main.php.net/note/delete/126706/useless
Del: bad code -- https://main.php.net/note/delete/126706/bad+code
Del: spam -- https://main.php.net/note/delete/126706/spam
Del: non-english -- https://main.php.net/note/delete/126706/non-english
Del: in docs -- https://main.php.net/note/delete/126706/in+docs
Del: other reasons-- https://main.php.net/note/delete/126706
Reject -- https://main.php.net/note/reject/126706
Search -- https://main.php.net/manage/user-notes.php