summaryrefslogtreecommitdiff
path: root/includes/helper
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-09-05 13:40:03 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2018-09-05 13:44:43 +0200
commit01e9c22695a3e495f07ab445750221af72e09fe4 (patch)
tree63c01a396d289f5f1e4d11259654e772300ff98c /includes/helper
parent9d34f371cb9c5ab0d60bd3158678b9cc9da6cc80 (diff)
Implemented mailing abstraction
Closes #434
Diffstat (limited to 'includes/helper')
-rw-r--r--includes/helper/email_helper.php37
1 files changed, 11 insertions, 26 deletions
diff --git a/includes/helper/email_helper.php b/includes/helper/email_helper.php
index a0631550..e9e5a323 100644
--- a/includes/helper/email_helper.php
+++ b/includes/helper/email_helper.php
@@ -1,5 +1,7 @@
<?php
+use Engelsystem\Mail\EngelsystemMailer;
+
/**
* @param array $recipient_user
* @param string $title
@@ -18,38 +20,21 @@ function engelsystem_email_to_user($recipient_user, $title, $message, $not_if_it
/** @var \Engelsystem\Helpers\Translator $translator */
$translator = app()->get('translator');
$locale = $translator->getLocale();
+ /** @var EngelsystemMailer $mailer */
+ $mailer = app('mailer');
$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"
- . $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);
-
- return engelsystem_email($recipient_user['email'], $title, $message);
-}
-
-/**
- * @param string $address
- * @param string $title
- * @param string $message
- * @return bool
- */
-function engelsystem_email($address, $title, $message)
-{
- $result = mail(
- $address,
+ $status = $mailer->sendView(
+ $recipient_user['email'],
$title,
- $message,
- sprintf(
- "Content-Type: text/plain; charset=UTF-8\r\nFrom: Engelsystem <%s>",
- config('no_reply_email')
- )
+ 'emails/mail',
+ ['user' => $recipient_user['Nick'], 'message' => $message]
);
+ $translator->setLocale($locale);
- if ($result === false) {
+ if (!$status) {
engelsystem_error('Unable to send email.');
}
- return true;
+ return (bool)$status;
}