You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
995 B
PHTML

<?php
use Engelsystem\Mail\EngelsystemMailer;
/**
* @param array $recipient_user
* @param string $title
* @param string $message
* @param bool $not_if_its_me
* @return bool
*/
8 years ago
function engelsystem_email_to_user($recipient_user, $title, $message, $not_if_its_me = false)
{
global $user;
8 years ago
8 years ago
if ($not_if_its_me && $user['UID'] == $recipient_user['UID']) {
return true;
}
8 years ago
/** @var \Engelsystem\Helpers\Translator $translator */
$translator = app()->get('translator');
$locale = $translator->getLocale();
/** @var EngelsystemMailer $mailer */
$mailer = app('mailer');
8 years ago
$translator->setLocale($recipient_user['Sprache']);
$status = $mailer->sendView(
$recipient_user['email'],
$title,
'emails/mail',
['user' => $recipient_user['Nick'], 'message' => $message]
);
$translator->setLocale($locale);
if (!$status) {
8 years ago
engelsystem_error('Unable to send email.');
}
return (bool)$status;
}