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.

56 lines
1.4 KiB
PHTML

<?php
/**
* @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();
8 years ago
$translator->setLocale($recipient_user['Sprache']);
$message = sprintf(_('Hi %s,'), $recipient_user['Nick']) . "\n\n"
. _('here is a message for you from the engelsystem:') . "\n\n"
8 years ago
. $message . "\n\n"
. _('This email is autogenerated and has not been signed. You got this email because you are registered in the engelsystem.');
$translator->setLocale($locale);
8 years ago
return engelsystem_email($recipient_user['email'], $title, $message);
}
/**
* @param string $address
* @param string $title
* @param string $message
* @return bool
*/
8 years ago
function engelsystem_email($address, $title, $message)
{
$result = mail(
$address,
$title,
$message,
sprintf(
"Content-Type: text/plain; charset=UTF-8\r\nFrom: Engelsystem <%s>",
config('no_reply_email')
)
);
8 years ago
if ($result === false) {
engelsystem_error('Unable to send email.');
}
return true;
}