diff --git a/src/api/wishlists.php b/src/api/wishlists.php index c7077368..af5d88cc 100644 --- a/src/api/wishlists.php +++ b/src/api/wishlists.php @@ -86,15 +86,17 @@ switch ($_SERVER['REQUEST_METHOD']) { $user = new User($wishlist['user']); $emailRequest = new Email($user->email, __('Wish request'), $mjml); - $emailRequest->send(); + $success = $emailRequest->send(); /** Save date to database */ - $database - ->query( - 'UPDATE `wishlists` - SET `notification_sent` = CURRENT_TIMESTAMP - WHERE `id` = ' . $wishlist['id'] . ';' - ); + if (true === $success) { + $database + ->query( + 'UPDATE `wishlists` + SET `notification_sent` = CURRENT_TIMESTAMP + WHERE `id` = ' . $wishlist['id'] . ';' + ); + } } $response['success'] = true; diff --git a/src/classes/email.php b/src/classes/email.php index 9bff5866..4827daaa 100644 --- a/src/classes/email.php +++ b/src/classes/email.php @@ -23,7 +23,7 @@ class Email ) { } - public function send() + public function send(): bool { global $options; @@ -56,5 +56,7 @@ class Email ); $success = mail($to, $subject, $message, $headers); + + return $success } }