summaryrefslogtreecommitdiff
path: root/app/ServiceProvider/MailerProvider.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-12-27 19:10:38 -0500
committerFrédéric Guillot <fred@kanboard.net>2014-12-27 19:10:38 -0500
commit17dc5bdc9ede52ad618bbf326e67e3b6988170f7 (patch)
tree9cf4d325667f11fa735bca84042fb385e3273329 /app/ServiceProvider/MailerProvider.php
parentcf821e117ce8b937cff7f386a107aaa81ba6bf9b (diff)
Move events handling to Symfony\EventDispatcher
Diffstat (limited to 'app/ServiceProvider/MailerProvider.php')
-rw-r--r--app/ServiceProvider/MailerProvider.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/app/ServiceProvider/MailerProvider.php b/app/ServiceProvider/MailerProvider.php
new file mode 100644
index 00000000..f6b71363
--- /dev/null
+++ b/app/ServiceProvider/MailerProvider.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace ServiceProvider;
+
+use Pimple\Container;
+use Pimple\ServiceProviderInterface;
+use Swift_SmtpTransport;
+use Swift_SendmailTransport;
+use Swift_MailTransport;
+
+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();
+ }
+
+ return $transport;
+ }
+}