Skip to content

Commit

Permalink
Add drivers for Mailgun, Mandrill, SES (#1169)
Browse files Browse the repository at this point in the history
  • Loading branch information
franzliedke committed Mar 16, 2019
1 parent 8c65316 commit c50d58d
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Mail/MailServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ public function register()
{
$this->app->singleton('mail.supported_drivers', function () {
return [
'smtp' => SmtpDriver::class,
'mail' => SendmailDriver::class,
'mailgun' => MailgunDriver::class,
'mandrill' => MandrillDriver::class,
'log' => LogDriver::class,
'ses' => SesDriver::class,
'smtp' => SmtpDriver::class,
];
});

Expand Down
29 changes: 29 additions & 0 deletions src/Mail/MailgunDriver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Flarum\Mail;

use Flarum\Settings\SettingsRepositoryInterface;
use GuzzleHttp\Client;
use Illuminate\Mail\Transport\MailgunTransport;
use Swift_Transport;

class MailgunDriver implements DriverInterface
{
public function buildTransport(SettingsRepositoryInterface $settings): Swift_Transport
{
return new MailgunTransport(
new Client(['connect_timeout' => 60]),
$settings->get('mail_mailgun_secret'),
$settings->get('mail_mailgun_domain')
);
}
}
28 changes: 28 additions & 0 deletions src/Mail/MandrillDriver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Flarum\Mail;

use Flarum\Settings\SettingsRepositoryInterface;
use GuzzleHttp\Client;
use Illuminate\Mail\Transport\MandrillTransport;
use Swift_Transport;

class MandrillDriver implements DriverInterface
{
public function buildTransport(SettingsRepositoryInterface $settings): Swift_Transport
{
return new MandrillTransport(
new Client(['connect_timeout' => 60]),
$settings->get('mail_mandrill_secret')
);
}
}
35 changes: 35 additions & 0 deletions src/Mail/SesDriver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Flarum\Mail;

use Aws\Ses\SesClient;
use Flarum\Settings\SettingsRepositoryInterface;
use Illuminate\Mail\Transport\SesTransport;
use Swift_Transport;

class SesDriver implements DriverInterface
{
public function buildTransport(SettingsRepositoryInterface $settings): Swift_Transport
{
$config = [
'version' => 'latest',
'service' => 'email',
'region' => $settings->get('mail_ses_region'),
'credentials' => [
'key' => $settings->get('mail_ses_key'),
'secret' => $settings->get('mail_ses_secret'),
],
];

return new SesTransport(new SesClient($config));
}
}

0 comments on commit c50d58d

Please sign in to comment.