-
Notifications
You must be signed in to change notification settings - Fork 8
/
MailtrapApiProvider.php
46 lines (41 loc) · 1.16 KB
/
MailtrapApiProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
declare(strict_types=1);
namespace Mailtrap\Bridge\Laravel;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\ServiceProvider;
use Mailtrap\Bridge\Transport\MailtrapTransportFactory;
use Symfony\Component\Mailer\Transport\Dsn;
/**
* Class MailtrapApiProvider
*/
class MailtrapApiProvider extends ServiceProvider
{
/**
* Register services.
*/
public function register(): void
{
$this->mergeConfigFrom(__DIR__ . '/config/mailtrap.php', 'services');
}
/**
* Bootstrap services.
*/
public function boot(): void
{
// https://laravel.com/docs/9.x/upgrade#symfony-mailer
if ((int) $this->app->version() >= 9) {
Mail::extend('mailtrap', function () {
return (new MailTrapTransportFactory)->create(
new Dsn(
'mailtrap+api',
config('services.mailtrap.host'),
config('services.mailtrap.apiKey'),
null,
null,
config('services.mailtrap', [])
)
);
});
}
}
}