summaryrefslogtreecommitdiff
path: root/app/Core/EmailClient.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Core/EmailClient.php')
-rw-r--r--app/Core/EmailClient.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/app/Core/EmailClient.php b/app/Core/EmailClient.php
new file mode 100644
index 00000000..980f5acc
--- /dev/null
+++ b/app/Core/EmailClient.php
@@ -0,0 +1,43 @@
+<?php
+
+namespace Core;
+
+/**
+ * Mail client
+ *
+ * @package core
+ * @author Frederic Guillot
+ */
+class EmailClient extends Base
+{
+ /**
+ * Send a HTML email
+ *
+ * @access public
+ * @param string $email
+ * @param string $name
+ * @param string $subject
+ * @param string $html
+ */
+ public function send($email, $name, $subject, $html)
+ {
+ $this->container['logger']->debug('Sending email to '.$email.' ('.MAIL_TRANSPORT.')');
+
+ $start_time = microtime(true);
+ $author = 'Kanboard';
+
+ if (Session::isOpen() && $this->userSession->isLogged()) {
+ $author = e('%s via Kanboard', $this->user->getFullname($this->session['user']));
+ }
+
+ switch (MAIL_TRANSPORT) {
+ case 'postmark':
+ $this->postmark->sendEmail($email, $name, $subject, $html, $author);
+ break;
+ default:
+ $this->smtp->sendEmail($email, $name, $subject, $html, $author);
+ }
+
+ $this->container['logger']->debug('Email sent in '.round(microtime(true) - $start_time, 6).' seconds');
+ }
+}