From 457f22c5cc3ce958690cb16e7ee44fc8aeeeeda0 Mon Sep 17 00:00:00 2001 From: ocjorge Date: Mon, 6 Jul 2026 23:21:57 -0600 Subject: [PATCH] fix: prevent fatal error when mail is not configured in Career Portal Without this change, CareerPortal::sendEmail() throws an uncaught PHPMailer exception when no mail server is configured, causing a fatal 500 error that prevents candidates from completing their application through the Career Portal. Wrapping the mail send in try/catch allows the application flow to continue normally when mail is unavailable, while still logging the error class and code for debugging without exposing sensitive SMTP configuration details in logs. Tested on PHP 8.4.21 + Debian 12 without a configured mail server. --- lib/CareerPortal.php | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/CareerPortal.php b/lib/CareerPortal.php index 68c44f8fb..85560aaf2 100755 --- a/lib/CareerPortal.php +++ b/lib/CareerPortal.php @@ -423,13 +423,24 @@ public function sendEmail($userID, $destination, $subject, $body) /* Send e-mail notification. */ //FIXME: Make subject configurable. - $mailer = new Mailer($userID); - $mailerStatus = $mailer->sendToOne( - array($destination, ''), - $subject, - $body, - true - ); + try + { + $mailer = new Mailer($userID); + $mailer->sendToOne( + array($destination, ''), + $subject, + $body, + true + ); + } + catch (\PHPMailer\PHPMailer\Exception $e) + { + // Mail not configured or unavailable - log and continue + error_log( + 'OpenCATS CareerPortal mail error: ' + . get_class($e) . ' [' . $e->getCode() . ']' + ); + } } }