Sometime we need to use more than one mail drivers to cover different areas, but now Laravel 5.3
only supports one, how can we extend it to support more mail drivers and be able to switch the drivers at runtime?
Asked
Active
Viewed 249 times
1

Suge
- 2,808
- 3
- 48
- 79
-
Possible duplicate of [multiple mail configurations](https://stackoverflow.com/questions/26546824/multiple-mail-configurations) – Adam Jul 09 '19 at 17:14
1 Answers
0
Like all Laravel classes, the mailer implements standard laravel interfaces:
class Mailer implements MailerContract, MailQueueContract
{
...
}
If you want to create your own mailers, then all you need to do is implement the contracts in your own class:
class MyMailer implements MailerContract, MailQueueContract
{
}
To use these different mailers, you will need to overide the register()
function in the MailServiceProvider
class to return the mailer instance you require.

GWed
- 15,167
- 5
- 62
- 99