From 15239f32c583938063db30d145da980a646deb91 Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Thu, 13 Nov 2025 14:37:28 +0100 Subject: [PATCH] fix(emails): catch server connection exceptions Signed-off-by: Anna Larch --- lib/MailQueueHandler.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/MailQueueHandler.php b/lib/MailQueueHandler.php index 4320329db..492373a26 100644 --- a/lib/MailQueueHandler.php +++ b/lib/MailQueueHandler.php @@ -61,10 +61,10 @@ public function __construct( /** * Send an email to {$limit} users * - * @param $limit Number of users we want to send an email to - * @param $sendTime The latest send time - * @param $forceSending Ignores latest send and just sends all emails - * @param $restrictEmails null or one of UserSettings::EMAIL_SEND_*, will overwrite force send + * @param int $limit Number of users we want to send an email to + * @param int $sendTime The latest send time + * @param bool $forceSending Ignores latest send and just sends all emails + * @param int|null $restrictEmails null or one of UserSettings::EMAIL_SEND_*, will overwrite force send * @return int Number of users we sent an email to */ public function sendEmails(int $limit, int $sendTime, bool $forceSending = false, ?int $restrictEmails = null): int { @@ -91,7 +91,13 @@ public function sendEmails(int $limit, int $sendTime, bool $forceSending = false continue; } - $userObject = $this->userManager->get($user); + try { + $userObject = $this->userManager->get($user); + } catch (\Exception $e) { + $this->logger->error('An error happened while trying to find ' . $user . ', skipping', ['exception' => $e]); + continue; + } + $email = $userObject ? $userObject->getEMailAddress() : ''; if (empty($email)) { // The user did not setup an email address