emchooo/laravel-flymail
Composer 安装命令:
composer require emchooo/laravel-flymail
包简介
Send mails in laravel with custom config you can set on the fly
README 文档
README
About
Laravel Flymail adds Mail::config() method to Laravel\Mail. Config method will setup mail config data on the fly. Use Flymail if you need to send Mails with dynamic credentials you store in DB or other configs. Since it just extends Laravel's Mail and adds config method, everything else remains same.
Installation
composer require emchooo/laravel-flymail
Usage
use Illuminate\Support\Facades\Mail; // get config file from DB or other source // SES config $config = [ 'driver' => 'ses', 'key' => 'xxx', 'secret' => 'xxx', 'from' => [ 'address' => 'address@mail.com', 'name' => 'Name' ] ]; // SMTP config $config = [ 'driver' => 'smtp', 'host' => 'smtp.xxx.io', 'port' => 2525, 'username' => 'xxx', 'password' => 'xxx', 'encription' => 'null' 'from' => [ 'address' => 'address@mail.com', 'name' => 'Name' ] ]; Mail::config($config)->to($request->user())->send(new OrderShipped($order));
NOTE ON QUEUES
If you use Mail::config than don't use ->queue(); , use ->send(); . If you use queue on Mail then it will use config from /config/mail.php while sending. Might try to fix that one day.
If you need to queue Mail with custom config then use Jobs.
SendEmail::dispatch($config, $order);
/** * Create a new job instance. * * @return void */ public function __construct($config, $order) { $this->config = $config; $this->order = $order; } /** * Execute the job. * * @return void */ public function handle() { Mail::config($this->config) ->to($this->order->email) ->send(new OrderShipped($this->order)); }
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 50
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-14