kevinzheng / laravel-switchable-mail
For Laravel to support multiple and switchable on runtime mail drivers.
Installs: 4 637
Dependents: 0
Suggesters: 0
Security: 0
Stars: 26
Watchers: 2
Forks: 20
Open Issues: 1
pkg:composer/kevinzheng/laravel-switchable-mail
Requires
- php: >=5.6.4
- illuminate/mail: 5.3.*
This package is not auto-updated.
Last update: 2025-10-26 02:36:06 UTC
README
It makes Laravel be able to maintain multiple mail drivers at the same time, and be able to send to different mail addresses with specified mail drivers as configured at runtime automatically.
Instructions
Installation
-
Install this package using the Composer manager:
composer require kevinzheng/laravel-switchable-mail
-
Replace
Illuminate\Mail\MailServiceProvider::classwithKVZ\Laravel\SwitchableMail\MailServiceProvider::classin theconfig/app.phpfile. -
Publish configuration file:
php artisan vendor:publish --tag=switchable-mail
Configuration
It uses the MAIL_DRIVER configured in .env as the default mail driver, for those addresses you want to send to with specified mail drivers, configure it at switchable-mail.php.
You should install the mail drivers not provided by Laravel at the meantime, such as Aliyun Direct Mail and SendCloud:
```php
// 'directmail' => [
// 'qq.com', '163.com', '126.com', 'sina.com', 'sina.com.cn', 'sohu.com',
// ],
// 'mailgun' => [
// 'example.com',
// ],
```
Two mail drivers are available:
Usage
Nothing needs to be done, just use Laravel Mail as usual.