diff options
author | emkael <emkael@tlen.pl> | 2016-11-01 00:20:05 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-11-01 00:20:05 +0100 |
commit | eb322a1a61237035718214ab4a1fce67c232262f (patch) | |
tree | 03df03233f86ae862e0c588617cb9f167cb04631 /app/frontend/mail/MailModule.php | |
parent | 6181693f1d4b021da8a699c19f5323a17ffab1de (diff) |
* PHPMailer-based mailer module
Diffstat (limited to 'app/frontend/mail/MailModule.php')
-rw-r--r-- | app/frontend/mail/MailModule.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/frontend/mail/MailModule.php b/app/frontend/mail/MailModule.php index 5f7749b..e10c556 100644 --- a/app/frontend/mail/MailModule.php +++ b/app/frontend/mail/MailModule.php @@ -1,16 +1,29 @@ <?php Prado::using('System.I18N.Globalization'); +Prado::using('Application.mail.Mailer'); Prado::using('Application.mail.MailTemplate'); Prado::using('Application.mail.MailTemplateTranslator'); class MailModule extends TModule { + private $_configPath; + private $_config; + private $_templatePath; private static $_templateExtension = 'html'; private $_templateCacheSubpath = 'mail'; private static $_templateTranslationCatalogue = 'messages'; + public function setConfigPath($configPath) { + $this->_configPath = TPropertyValue::ensureString($configPath); + $this->_config = json_decode( + file_get_contents( + Prado::getPathOfNamespace($this->_configPath, '.json') + ) + ); + } + public function setTemplatePath($templatePath) { $this->_templatePath = Prado::getPathOfNamespace( TPropertyValue::ensureString($templatePath) @@ -90,6 +103,19 @@ class MailModule extends TModule { return $template; } + public function getMailer() { + if (!$this->_config) { + throw new TConfigurationException( + Prado::localize( + 'Mailer not configured' + ) + ); + } + $mailer = new Mailer(); + $mailer->configure($this->_config); + return $mailer; + } + } ?> |