justijndepover / laravel-inbox
拦截Laravel应用程序中的发出的电子邮件
0.5.0
2020-12-04 14:35 UTC
Requires (Dev)
- orchestra/testbench: ^6.2
README
将收件箱界面添加到您的应用程序中以监控所有发出的电子邮件。
注意
此应用程序仍在开发中,可能实现破坏性更改。请自行承担风险。
安装
您可以使用composer安装此包
composer require justijndepover/laravel-inbox
安装后,您需要发布资源和执行迁移。
php artisan inbox:install --migration
如果需要,您也可以立即发布配置文件
php artisan inbox:install --config
这是配置文件
return [ /* * This setting determines if the Laravel Inbox package should Listen * to Sending mail events. */ 'listener_enabled' => (config('app.env') != 'production'), /* * This setting determines if the Laravel Inbox package should open up * the endpoint to view the inbox application. */ 'application_enabled' => (config('app.env') != 'production'), /* * This is the URI path where Laravel Inbox will be accessible from. */ 'path' => 'inbox', /* * These middleware will get attached onto each Laravel Inbox route, giving you * the chance to add your own middleware to this list or change any of * the existing middleware. Or, you can simply stick with this list. */ 'middleware' => ['web'], ];
使用方法
应用程序将在/inbox
处暴露一个端点。
默认情况下,如果您的应用程序环境未设置为生产模式,则此包才会正常工作。您可以通过覆盖inbox.listener_enabled
和inbox.application_enabled
设置来更改此行为。
授权
/inbox
端点对所有人均可用。如果您想保护此路由,可以注册以下网关。
use Illuminate\Support\Facades\Gate; Gate::define('viewInbox', function ($user) { // your logic here return $user->isAdmin(); });
一个好的做法是在Laravel默认提供的AuthServiceProvider
中进行此操作。
用例
创建此包的主要目的是提供mailtrap的替代方案。这也是为什么此包仅在应用程序不是生产模式时才工作。
如果您出于相同原因想使用此包,建议在env文件中将邮件驱动设置为log
,以防止应用程序实际发送电子邮件。
MAIL_MAILER=log
安全
如果您发现任何安全相关的问题,请提交问题或直接通过justijndepover@gmail.com联系我。
贡献
如果您想对此包进行任何更改或改进,请随时提交拉取请求。
许可证
MIT许可证(MIT)。有关更多信息,请参阅许可证文件。