summaryrefslogtreecommitdiff
path: root/app/frontend/mail/Mailer.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/frontend/mail/Mailer.php')
-rw-r--r--app/frontend/mail/Mailer.php19
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);
+ }
+ }
+
}
?>