|
|
|
@ -13,12 +13,14 @@ 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');
|
|
|
|
|
|
|
|
|
@ -29,10 +31,15 @@ function engelsystem_email_to_user($recipientUser, $title, $message, $notIfItsMe
|
|
|
|
|
'emails/mail',
|
|
|
|
|
['username' => $recipientUser->name, 'message' => $message]
|
|
|
|
|
);
|
|
|
|
|
} catch(Exception $e) {
|
|
|
|
|
$status = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$translator->setLocale($locale);
|
|
|
|
|
|
|
|
|
|
if (!$status) {
|
|
|
|
|
engelsystem_error('Unable to send email.');
|
|
|
|
|
error(sprintf(__('User %s could not be notified by email due to an error.'), User_Nick_render($recipientUser)));
|
|
|
|
|
engelsystem_log(sprintf('User %s could not be notified by email due to an error.', $recipientUser->name));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (bool)$status;
|
|
|
|
|