From 60a158e28152b60a4446ee21bed8e1282b16f3e5 Mon Sep 17 00:00:00 2001 From: agungsugiarto Date: Thu, 3 Jun 2021 15:26:26 +0700 Subject: [PATCH] log email when failed to send --- src/Notifications/ResetPasswordNotification.php | 13 ++++++++++--- src/Notifications/VerificationNotification.php | 15 +++++++++++---- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/Notifications/ResetPasswordNotification.php b/src/Notifications/ResetPasswordNotification.php index 1d90c27..4771578 100644 --- a/src/Notifications/ResetPasswordNotification.php +++ b/src/Notifications/ResetPasswordNotification.php @@ -33,7 +33,7 @@ public function __construct(string $email, string $token) */ public function send() { - return $this->service + $this->service ->setTo($this->email) ->setSubject("Reset Password Notification") ->setMessage(view('Fluent\Auth\Views\Email\reset_email', [ @@ -41,7 +41,14 @@ public function send() 'email' => $this->email, 'expire' => config('Auth')->passwords[config('Auth')->defaults['password']]['expire'], ])) - ->setMailType('html') - ->send(); + ->setMailType('html'); + + if (! $this->service->send()) { + log_message('error', $this->service->printDebugger()); + + return false; + } + + return true; } } diff --git a/src/Notifications/VerificationNotification.php b/src/Notifications/VerificationNotification.php index fd660e0..8af8ac1 100644 --- a/src/Notifications/VerificationNotification.php +++ b/src/Notifications/VerificationNotification.php @@ -30,7 +30,7 @@ public function __construct(string $email) */ public function send() { - return $this->service + $this->service ->setTo($this->email) ->setSubject('Verify Email Notification') ->setMessage(view('Fluent\Auth\Views\Email\verify_email', [ @@ -38,7 +38,14 @@ public function send() 'expire' => Time::now()->addMinutes(config('Auth')->passwords[config('Auth')->defaults['password']]['expire'])->getTimestamp(), 'signature' => hash_hmac('sha256', $this->email, config('Encryption')->key), ])) - ->setMailType('html') - ->send(); + ->setMailType('html'); + + if (! $this->service->send()) { + log_message('error', $this->service->printDebugger()); + + return false; + } + + return true; } -} +} \ No newline at end of file