diff options
author | Joas Schilling <coding@schilljs.com> | 2022-10-06 09:44:14 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-10-06 09:44:14 +0300 |
commit | 98e25e706bf5a8f6f92d532dc0cba33daaf42b21 (patch) | |
tree | 4cd93ca8a968fc53bc257b991910c2a66654c58a | |
parent | 21b0ae2be952445aa35d3150c5a0b8bfbc1f10c9 (diff) |
Improve debugging of failing emails
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | lib/MailNotifications.php | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/MailNotifications.php b/lib/MailNotifications.php index 990ec6b..7fad5e0 100644 --- a/lib/MailNotifications.php +++ b/lib/MailNotifications.php @@ -276,15 +276,26 @@ class MailNotifications { $notifications = array_reverse($notifications); foreach ($notifications as $notification) { - $relativeDateTime = $this->dateFormatter->formatDateTimeRelativeDay($notification->getDateTime(), 'long', 'short', new \DateTimeZone($timezone), $l10n); - $template->addBodyListItem($this->getHTMLContents($notification), $relativeDateTime, $notification->getIcon(), $notification->getParsedSubject()); - - // Buttons probably were not intended for this, but it works ok enough for showing the idea. - $actions = $notification->getParsedActions(); - foreach ($actions as $action) { - if ($action->getRequestType() === IAction::TYPE_WEB) { - $template->addBodyButton($action->getLabel(), $action->getLink()); + try { + $relativeDateTime = $this->dateFormatter->formatDateTimeRelativeDay($notification->getDateTime(), 'long', 'short', new \DateTimeZone($timezone), $l10n); + $template->addBodyListItem($this->getHTMLContents($notification), $relativeDateTime, $notification->getIcon(), $notification->getParsedSubject()); + + // Buttons probably were not intended for this, but it works ok enough for showing the idea. + $actions = $notification->getParsedActions(); + foreach ($actions as $action) { + if ($action->getRequestType() === IAction::TYPE_WEB) { + $template->addBodyButton($action->getLabel(), $action->getLink()); + } } + } catch (\Throwable $e) { + $this->logger->error( + 'An error occurred while preparing a notification (' + . $notification->getApp() . '|' . $notification->getSubject() + . '|' . $notification->getObjectType() . '|' . $notification->getObjectId() + . ') for sending', [ + 'exception' => $e, + ]); + return null; } } |