summaryrefslogtreecommitdiff
path: root/includes/helper
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2019-04-29 23:17:58 +0200
committermsquare <msquare@notrademark.de>2019-04-30 18:09:08 +0200
commitca0b2d8b5f650aad37b2d53577379efb4b468044 (patch)
treeb57ae5b4a9c3710223a94be691d682ca5db91a6b /includes/helper
parent9829e6da390c8a62f322e085cbf5b48a586446a0 (diff)
Improved email error logging
Diffstat (limited to 'includes/helper')
-rw-r--r--includes/helper/email_helper.php16
1 files changed, 12 insertions, 4 deletions
diff --git a/includes/helper/email_helper.php b/includes/helper/email_helper.php
index 802debaa..bad0d539 100644
--- a/includes/helper/email_helper.php
+++ b/includes/helper/email_helper.php
@@ -2,6 +2,7 @@
use Engelsystem\Mail\EngelsystemMailer;
use Engelsystem\Models\User\User;
+use Psr\Log\LogLevel;
/**
* @param User $recipientUser
@@ -13,17 +14,17 @@ use Engelsystem\Models\User\User;
function engelsystem_email_to_user($recipientUser, $title, $message, $notIfItsMe = false)
{
if ($notIfItsMe && auth()->user()->id == $recipientUser->id) {
- #return true;
+ return true;
}
/** @var \Engelsystem\Helpers\Translator $translator */
$translator = app()->get('translator');
$locale = $translator->getLocale();
-
+
try {
/** @var EngelsystemMailer $mailer */
$mailer = app('mailer');
-
+
$translator->setLocale($recipientUser->settings->language);
$status = $mailer->sendView(
$recipientUser->contact->email ? $recipientUser->contact->email : $recipientUser->email,
@@ -31,8 +32,15 @@ function engelsystem_email_to_user($recipientUser, $title, $message, $notIfItsMe
'emails/mail',
['username' => $recipientUser->name, 'message' => $message]
);
- } catch(Exception $e) {
+ } catch (Exception $e) {
$status = 0;
+ engelsystem_log(sprintf(
+ 'An exception occurred while sending a mail to %s in %s:%u: %s',
+ $recipientUser->name,
+ $e->getFile(),
+ $e->getLine(),
+ $e->getMessage()
+ ), LogLevel::CRITICAL);
}
$translator->setLocale($locale);