diff options
author | Zoltan Flamis <zoltan@innocraft.com> | 2021-05-27 01:28:59 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-27 01:28:59 +0300 |
commit | 70b05de003487a31495bb9927017606a2faab7dd (patch) | |
tree | 3dcdcf0d6dc2298f356248f88d8f2e51e214afb2 /core/Mail.php | |
parent | 30583c72fbb57469ee953536f69af2859fef61db (diff) |
Email notifications for critical actions (#17531)
* wip email notifications
* use Mail class
* token and login settings notification emails
* more notification emails
* user created/deleted notification
* use an abstract class
* import class
* catch email ex
* wip
* change settings changed emails
* import loggerinterface
* simpler email bodies
* some small tweaks to the translations
Co-authored-by: diosmosis <diosmosis@users.noreply.github.com>
Diffstat (limited to 'core/Mail.php')
-rw-r--r-- | core/Mail.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/core/Mail.php b/core/Mail.php index 8c6330715b..2a97929b92 100644 --- a/core/Mail.php +++ b/core/Mail.php @@ -8,10 +8,13 @@ */ namespace Piwik; +use DI\NotFoundException; +use DI\DependencyException; use Piwik\Container\StaticContainer; use Piwik\Email\ContentGenerator; use Piwik\Plugins\CoreAdminHome\CustomLogo; use Piwik\Translation\Translator; +use Psr\Log\LoggerInterface; /** * Class for sending mails @@ -290,6 +293,23 @@ class Mail } /** + * If the send email process throws an exception, we catch it and log it + * + * @return void + * @throws NotFoundException + * @throws DependencyException + */ + public function safeSend() + { + try { + $this->send(); + } catch (\Exception $e) { + // we do nothing but log if the email send was unsuccessful + StaticContainer::get(LoggerInterface::class)->warning('Could not send {class} email: {exception}', ['class' => get_class($this), 'exception' => $e]); + } + } + + /** * Enables SMTP debugging * * @param bool $smtpDebug |