diff options
author | emkael <emkael@tlen.pl> | 2016-11-03 23:29:15 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-11-03 23:31:39 +0100 |
commit | fc36e60cc8f2b5a5919a6262571868365a209d17 (patch) | |
tree | d037fb8ef2ecad64307427d89a81be70d528d579 /app/frontend/mail/Mailer.php | |
parent | bef5754e4676a8a578550b6af24d050a946405eb (diff) |
* mail queueing, depending on the template
Diffstat (limited to 'app/frontend/mail/Mailer.php')
-rw-r--r-- | app/frontend/mail/Mailer.php | 19 |
1 files changed, 16 insertions, 3 deletions
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 @@ <?php Prado::using('Lib.phpmailer.PHPMailerAutoload'); +Prado::using('Application.mail.MailModule'); Prado::using('Application.mail.MailTemplate'); class Mailer extends PHPMailer { + private $_module; + public function __construct() { $this->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); + } + } + } ?> |