mirror of
https://github.com/flarum/framework.git
synced 2025-02-06 16:51:02 +08:00
Add drivers for Mailgun, Mandrill, SES (#1169)
This commit is contained in:
parent
f3e4496930
commit
93ab68e5c4
|
@ -22,9 +22,12 @@ class MailServiceProvider extends AbstractServiceProvider
|
|||
{
|
||||
$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,
|
||||
];
|
||||
});
|
||||
|
||||
|
|
29
framework/core/src/Mail/MailgunDriver.php
Normal file
29
framework/core/src/Mail/MailgunDriver.php
Normal file
|
@ -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
framework/core/src/Mail/MandrillDriver.php
Normal file
28
framework/core/src/Mail/MandrillDriver.php
Normal file
|
@ -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
framework/core/src/Mail/SesDriver.php
Normal file
35
framework/core/src/Mail/SesDriver.php
Normal file
|
@ -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));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user