note 126706 deleted from function.mail by cmb

From: Date: Thu, 23 Dec 2021 15:08:55 +0000
Subject: note 126706 deleted from function.mail by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-217408@lists.php.net to get a copy of this message
Note Submitter: Saqib ---- 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/

« previous php.notes (#217408) next »