engelsystem/includes/helper/email_helper.php

54 lines
1.3 KiB
PHP
Raw Normal View History

2013-12-26 13:34:48 +01:00
<?php
2017-01-03 03:22:48 +01:00
/**
* @param array $recipient_user
* @param string $title
* @param string $message
* @param bool $not_if_its_me
* @return bool
*/
2017-01-02 03:57:23 +01:00
function engelsystem_email_to_user($recipient_user, $title, $message, $not_if_its_me = false)
{
global $user;
2017-01-02 15:43:36 +01:00
2017-01-02 03:57:23 +01:00
if ($not_if_its_me && $user['UID'] == $recipient_user['UID']) {
return true;
}
2017-01-02 15:43:36 +01:00
2017-01-02 03:57:23 +01:00
gettext_locale($recipient_user['Sprache']);
2017-01-02 15:43:36 +01:00
2017-01-03 14:12:17 +01:00
$message = sprintf(_('Hi %s,'), $recipient_user['Nick']) . "\n\n"
. _('here is a message for you from the engelsystem:') . "\n\n"
2017-01-02 15:43:36 +01:00
. $message . "\n\n"
2017-12-27 08:48:45 +01:00
. _('This email is autogenerated and has not been signed. You got this email because you are registered in the engelsystem.');
2017-01-02 15:43:36 +01:00
2017-01-02 03:57:23 +01:00
gettext_locale();
2017-01-03 03:22:48 +01:00
2017-01-02 03:57:23 +01:00
return engelsystem_email($recipient_user['email'], $title, $message);
2013-12-26 13:34:48 +01:00
}
2017-01-03 03:22:48 +01:00
/**
* @param string $address
* @param string $title
* @param string $message
* @return bool
*/
2017-01-02 03:57:23 +01:00
function engelsystem_email($address, $title, $message)
{
2017-01-03 03:22:48 +01:00
$result = mail(
$address,
$title,
$message,
2017-12-25 23:12:52 +01:00
sprintf(
"Content-Type: text/plain; charset=UTF-8\r\nFrom: Engelsystem <%s>",
config('no_reply_email')
)
2017-01-03 03:22:48 +01:00
);
2017-01-02 03:57:23 +01:00
if ($result === false) {
engelsystem_error('Unable to send email.');
}
2017-01-03 03:22:48 +01:00
return true;
2013-12-26 13:34:48 +01:00
}