Skip to content

Commit

Permalink
Add mailgun, mandrill and log mail transport.
Browse files Browse the repository at this point in the history
Signed-off-by: crynobone <crynobone@gmail.com>
  • Loading branch information
crynobone committed May 4, 2014
1 parent 3fc38bc commit 439ce02
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions src/Notifier/Mailer.php
Expand Up @@ -4,6 +4,9 @@
use InvalidArgumentException;
use Illuminate\Support\SerializableClosure;
use Illuminate\Mail\Mailer as M;
use Illuminate\Mail\Transport\LogTransport;
use Illuminate\Mail\Transport\MailgunTransport;
use Illuminate\Mail\Transport\MandrillTransport;
use Orchestra\Memory\ContainerTrait;
use Swift_Mailer;
use Swift_SmtpTransport as SmtpTransport;
Expand Down Expand Up @@ -190,6 +193,15 @@ protected function registerSwiftTransport($config)
case 'mail':
return $this->registerMailTransport($config);

case 'mailgun':
return $this->registerMailgunTransport($config);

case 'mandrill':
return $this->registerMandrillTransport($config);

case 'log':
return $this->registerLogTransport($config);

default:
throw new InvalidArgumentException('Invalid mail driver.');
}
Expand Down Expand Up @@ -242,4 +254,43 @@ protected function registerMailTransport($config)
unset($config);
return MailTransport::newInstance();
}

/**
* Register the Mailgun Swift Transport instance.
*
* @param array $config
* @return void
*/
protected function registerMailgunTransport($config)
{
$this->app->bindShared('swift.transport', function() use ($config) {
return new MailgunTransport($config['secret'], $config['domain']);
});
}

/**
* Register the Mandrill Swift Transport instance.
*
* @param array $config
* @return void
*/
protected function registerMandrillTransport($config)
{
$this->app->bindShared('swift.transport', function() use ($config) {
return new MandrillTransport($config['secret']);
});
}

/**
* Register the "Log" Swift Transport instance.
*
* @param array $config
* @return void
*/
protected function registerLogTransport($config)
{
$this->app->bindShared('swift.transport', function($app) {
return new LogTransport($app['log']->getMonolog());
});
}
}

0 comments on commit 439ce02

Please sign in to comment.