From 328753cd595738bc14d27fd6058bbe310b34f3f4 Mon Sep 17 00:00:00 2001 From: Akhil Date: Mon, 18 Sep 2023 23:54:18 +0530 Subject: [PATCH 1/2] Fix error logging when email not sent --- lib/Service/UserService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Service/UserService.php b/lib/Service/UserService.php index c1ccdc31..8ba4aace 100644 --- a/lib/Service/UserService.php +++ b/lib/Service/UserService.php @@ -168,7 +168,7 @@ class UserService { $email = $this->createSendGridEmail($fromEmail, $fromName, $toEmail, $toName, $templateID, $uid, $mainDomain); $this->sendEmailWithSendGrid($email, $sendgridAPIkey); } catch (Throwable $e) { - $this->logger->error($e, ['app' => Application::APP_ID]); + $this->logger->error('Error sending email to: ' . $email . ': ' . $e->getMessage()); } } private function getSendGridAPIKey() : string { -- GitLab From 4d6dd0c5230cdeed68839b94c0c5dbca0388016c Mon Sep 17 00:00:00 2001 From: Akhil Date: Tue, 19 Sep 2023 00:18:04 +0530 Subject: [PATCH 2/2] Set curl timeout of 15 seconds --- lib/Service/UserService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Service/UserService.php b/lib/Service/UserService.php index 8ba4aace..8803fcd9 100644 --- a/lib/Service/UserService.php +++ b/lib/Service/UserService.php @@ -197,7 +197,7 @@ class UserService { } private function sendEmailWithSendGrid(\SendGrid\Mail\Mail $email, string $sendgridAPIkey): void { $sendgrid = new \SendGrid($sendgridAPIkey); - $response = $sendgrid->send($email); + $response = $sendgrid->send($email, [ CURLOPT_TIMEOUT => 15 ]); if ($response->statusCode() !== 200) { throw new \Exception("SendGrid API error - Status Code: " . $response->statusCode()); -- GitLab