Skip to content

Commit

Permalink
Add advanced Swiftmailer configuration (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
bedrich-schindler authored and wernerdweight committed May 23, 2018
1 parent da9ac4e commit c90577e
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions Microbe.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,34 @@ public function __construct($configuration = [], $env = 'prod'){
]);
}

/// initialize mailer
$mailer = null;
if(isset($configuration['swiftmailer']) && $configuration['swiftmailer']['enable'] === true){
$transport = \Swift_MailTransport::newInstance();
$mailer = \Swift_Mailer::newInstance($transport);
}
/// initialize mailer
$mailer = null;
$mailerConfig = $configuration['swiftmailer'];
if(isset($mailerConfig) && isset($mailerConfig['enable']) && $mailerConfig['enable'] === true){
$transport = \Swift_MailTransport::newInstance();

if (isset($mailerConfig['transport']) && $mailerConfig['transport'] === 'smtp') {
$transport = \Swift_SmtpTransport::newInstance(
isset($mailerConfig['host']) ? $mailerConfig['host'] : null,
isset($mailerConfig['port']) ? $mailerConfig['port'] : null,
isset($mailerConfig['encryption']) ? $mailerConfig['encryption'] : null
);

if (isset($mailerConfig['auth_mode'])) {
$transport = $transport->setAuthMode($mailerConfig['auth_mode']);
}

if (isset($mailerConfig['username'])) {
$transport = $transport->setUsername($mailerConfig['username']);
}

if (isset($mailerConfig['password'])) {
$transport = $transport->setPassword($mailerConfig['password']);
}
}

$mailer = \Swift_Mailer::newInstance($transport);
}

/// initialize gatekeeper
$gatekeeper = Gatekeeper::getInstance();
Expand Down

0 comments on commit c90577e

Please sign in to comment.