diff options
author | Frédéric Guillot <fred@kanboard.net> | 2015-01-02 17:19:13 -0500 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2015-01-02 17:19:13 -0500 |
commit | 3076ba22dd8346725b4e1ad757532c00df5b18d9 (patch) | |
tree | e893c113c34d86c5dc923953754dc68c4b1d842d /app/ServiceProvider/MailerProvider.php | |
parent | c32567857db9bb1a6dfa339f58d817c97f64db11 (diff) |
Fix bugs, improve perfs and use SimpleLogger instead of Monolog
Diffstat (limited to 'app/ServiceProvider/MailerProvider.php')
-rw-r--r-- | app/ServiceProvider/MailerProvider.php | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/app/ServiceProvider/MailerProvider.php b/app/ServiceProvider/MailerProvider.php index f6b71363..6469a737 100644 --- a/app/ServiceProvider/MailerProvider.php +++ b/app/ServiceProvider/MailerProvider.php @@ -12,25 +12,22 @@ class MailerProvider implements ServiceProviderInterface { public function register(Container $container) { - $container['mailer'] = $this->getInstance(); - } - - public function getInstance() - { - switch (MAIL_TRANSPORT) { - case 'smtp': - $transport = Swift_SmtpTransport::newInstance(MAIL_SMTP_HOSTNAME, MAIL_SMTP_PORT); - $transport->setUsername(MAIL_SMTP_USERNAME); - $transport->setPassword(MAIL_SMTP_PASSWORD); - $transport->setEncryption(MAIL_SMTP_ENCRYPTION); - break; - case 'sendmail': - $transport = Swift_SendmailTransport::newInstance(MAIL_SENDMAIL_COMMAND); - break; - default: - $transport = Swift_MailTransport::newInstance(); - } + $container['mailer'] = function () { + switch (MAIL_TRANSPORT) { + case 'smtp': + $transport = Swift_SmtpTransport::newInstance(MAIL_SMTP_HOSTNAME, MAIL_SMTP_PORT); + $transport->setUsername(MAIL_SMTP_USERNAME); + $transport->setPassword(MAIL_SMTP_PASSWORD); + $transport->setEncryption(MAIL_SMTP_ENCRYPTION); + break; + case 'sendmail': + $transport = Swift_SendmailTransport::newInstance(MAIL_SENDMAIL_COMMAND); + break; + default: + $transport = Swift_MailTransport::newInstance(); + } - return $transport; + return $transport; + }; } } |