summaryrefslogtreecommitdiff
path: root/src/Mail/EngelsystemMailer.php
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 /src/Mail/EngelsystemMailer.php
parent9d34f371cb9c5ab0d60bd3158678b9cc9da6cc80 (diff)
Implemented mailing abstraction
Closes #434
Diffstat (limited to 'src/Mail/EngelsystemMailer.php')
-rw-r--r--src/Mail/EngelsystemMailer.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/Mail/EngelsystemMailer.php b/src/Mail/EngelsystemMailer.php
new file mode 100644
index 00000000..17047cc8
--- /dev/null
+++ b/src/Mail/EngelsystemMailer.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace Engelsystem\Mail;
+
+use Engelsystem\Renderer\Renderer;
+use Swift_Mailer as SwiftMailer;
+
+class EngelsystemMailer extends Mailer
+{
+ /** @var Renderer|null */
+ protected $view;
+
+ public function __construct(SwiftMailer $mailer, Renderer $view = null)
+ {
+ parent::__construct($mailer);
+
+ $this->view = $view;
+ }
+
+ /**
+ * Send a template
+ *
+ * @param string $to
+ * @param string $subject
+ * @param string $template
+ * @param array $data
+ * @return int
+ */
+ public function sendView($to, $subject, $template, $data = []): int
+ {
+ $body = $this->view->render($template, $data);
+
+ return $this->send($to, $subject, $body);
+ }
+}