kevinzheng / laravel-switchable-mail by kevinzheng

For Laravel to support multiple and switchable on runtime mail drivers.
4,631
26
2
Package Data
Maintainer Username: kevinzheng
Maintainer Contact: realkvz@gmail.com (Kevin Zheng)
Package Create Date: 2016-11-23
Package Last Update: 2016-11-26
Language: PHP
License: MIT
Last Refreshed: 2024-04-23 03:02:18
Package Statistics
Total Downloads: 4,631
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 26
Total Watchers: 2
Total Forks: 22
Total Open Issues: 2

laravel-switchable-mail

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

English

中文简体

Installation

  1. Install this package using the Composer manager:

    composer require kevinzheng/laravel-switchable-mail
    
  2. Replace Illuminate\Mail\MailServiceProvider::class with KVZ\Laravel\SwitchableMail\MailServiceProvider::class in the config/app.php file.

  3. 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:

laravel-directmail

laravel-sendcloud

Usage

Nothing needs to be done, just use Laravel Mail as usual.

Thanks to

ElfSundae