From fc36e60cc8f2b5a5919a6262571868365a209d17 Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 3 Nov 2016 23:29:15 +0100 Subject: * mail queueing, depending on the template --- app/frontend/mail/Mailer.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'app/frontend/mail/Mailer.php') diff --git a/app/frontend/mail/Mailer.php b/app/frontend/mail/Mailer.php index 3b95568..cd08757 100644 --- a/app/frontend/mail/Mailer.php +++ b/app/frontend/mail/Mailer.php @@ -1,16 +1,21 @@ isSMTP(); $this->SMTPAuth = TRUE; } - public function configure($config) { + public function configure(MailModule $module) { + $this->_module = $module; + $config = $module->getConfig(); $this->Host = $config->smtp->host; $this->Port = $config->smtp->port; $this->Username = $config->smtp->user; @@ -24,11 +29,10 @@ class Mailer extends PHPMailer { } } - public function sendTemplate(MailTemplate $template, string $subject, string $to, string $name) { + protected function _sendImmediate(string $subject, string $html, string $to, string $name) { $this->addAddress($to, $name); $this->isHTML(TRUE); $this->Subject = $subject; - $html = $template->execute(); $this->Body = $html; $this->AltBody = strip_tags($html); $result = $this->send(); @@ -36,6 +40,15 @@ class Mailer extends PHPMailer { return $result; } + public function sendTemplate(MailTemplate $template, string $subject, string $to, string $name) { + $html = $template->execute(); + if ($template->isImmediate()) { + return $this->_sendImmediate($subject, $html, $to, $name); + } else { + return $this->_module->queueMail($subject, $html, $to, $name); + } + } + } ?> -- cgit v1.2.3