distilleries/mailersaver
Composer 安装命令:
composer require distilleries/mailersaver
包简介
Override helper Mailer from laravel to hook the sender
README 文档
README
Laravel 5 MailerSaver
Mailer saver extend the laravel 5 mailer.
- Add the possibility to override the to,cc,bcc of your mail without modify your implementation.
- Add the possibility to get your template mail, subject, cc, bcc and type from a model.
Table of contents
Installation
Add on your composer.json
"require": { "distilleries/mailersaver": "2.*", }
run composer update.
Add Service provider to config/app.php:
'providers' => [ // ... Distilleries\MailerSaver\MailerSaverServiceProvider::class, Wpb\String_Blade_Compiler\ViewServiceProvider::class, ],
And Facade (also in config/app.php) replace the laravel facade Mail
'aliases' => [ // ... 'Mail' => 'Distilleries\MailerSaver\Facades\Mail', ]
You need to provide a model of data, simply add on your register method a new instance of your model in your app/Providers/AppServiceProvider.php:
public function register() { $this->app->singleton('Distilleries\MailerSaver\Contracts\MailModelContract', function ($app) { return new App\Email; }); }
In this case I return a Email model instance.
This model just implement the contract Distilleries\MailerSaver\Contracts\MailModelContract.
To Publish the model:
php artisan vendor:publish --provider="Distilleries\MailerSaver\MailerSaverServiceProvider" --tag="models"
To Publish the migration:
php artisan vendor:publish --provider="Distilleries\MailerSaver\MailerSaverServiceProvider" --tag="migrations"
Config file
You can publish the config file with the command line:
php artisan vendor:publish --provider="Distilleries\MailerSaver\MailerSaverServiceProvider"
return [ 'template' => 'mailersaver::default', 'override' => [ 'enabled' => env('MAILERSAVER_ENABLED', false), 'to' => env('MAILERSAVER_TO', 'default1@mailto.com,default2@mailto.com'), 'cc' => env('MAILERSAVER_CC', ''), 'bcc' => env('MAILERSAVER_BCC', ''), ], ];
| Field | Description |
|---|---|
| template | Global template when you put the content of your mail. |
| override | An array with all the config to hoock the mail send. |
| enabled | Enable the override of the mail. If in true that send the email with the to, cc, bcc |
| to | Use to send an email when the override parameter is set to true |
| cc | Use to send an email when the override parameter is set to true |
| bcc | Use to send an email when the override parameter is set to true |
View
To override the view you can give a new template on the configuration or modify the current one. Before modify it you have to publish it:
php artisan vendor:publish --provider="Distilleries\MailerSaver\MailerSaverServiceProvider" --tag="views"
Send an email
It's exactly the same than the laravel mailer.
Example:
Mail::send('emails.welcome', ['key' => 'value'], function ($message) { $message->to('foo@example.com', 'John Smith')->subject('Welcome!'); });
If the override is set to true email is send to another to email address.
Troubleshooting
If composer update --require-dev refuse to install, remove illuminate/* from vendor before the install or just remove vendor and start fresh.
distilleries/mailersaver 适用场景与选型建议
distilleries/mailersaver 是一款 基于 HTML 开发的 Composer 扩展包,目前已累计 3.43k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 02 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 distilleries/mailersaver 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 distilleries/mailersaver 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3.43k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-02-16