diff options
Diffstat (limited to 'app/frontend/mail/Mailer.php')
-rw-r--r-- | app/frontend/mail/Mailer.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/app/frontend/mail/Mailer.php b/app/frontend/mail/Mailer.php new file mode 100644 index 0000000..327c9af --- /dev/null +++ b/app/frontend/mail/Mailer.php @@ -0,0 +1,41 @@ +<?php + +Prado::using('Lib.phpmailer.PHPMailerAutoload'); +Prado::using('Application.mail.MailTemplate'); + +class Mailer extends PHPMailer { + + public function __construct() { + $this->isSMTP(); + $this->SMTPAuth = TRUE; + } + + public function configure($config) { + $this->Host = $config->smtp->host; + $this->Port = $config->smtp->port; + $this->Username = $config->smtp->user; + $this->Password = $config->smtp->pass; + if ($config->smtp->tls) { + $this->SMTPSecure = 'tls'; + } + $this->setFrom($config->mail->from, $config->mail->name); + if ($config->mail->send_copies) { + $this->addBCC($config->mail->from); + } + } + + public function sendTemplate(MailTemplate $template, $subject, $to, $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(); + $this->clearAddresses(); + return $result; + } + +} + +?> |