[扩展推荐] Laravel Email 查看器,现在你能很方便地调试 Email 发送功能
Laravel Email 查看器是由 Harish Toshniwal 开发的扩展包,它可以让你在一个页面中查看到所有 Laravel 应用中发送的邮件。
设计和内容团队成员经常需要查看应用中发送给用户的邮件,使用这个包可以很容易地实现该需求,并尽量最小化人们对开发者的依赖性。通过使用这个包,你将有一个专门用于查看应用中所有邮件的 URL,这些 URL 都是可分享的,这将使团队写作更顺畅。
我发现这个想法同时也适合开发者,因为我总是浏览所有的测试邮件去查看邮件,而这个扩展包可以让你在一个地方方便地查看这些它们。
通过配置选择你想展示的邮件内容,这意味着新增的邮件内容,你都需要明确定义他们。你也可以通过环境变量来约束可访问的邮件。
以下是来自于自述文件的简单示例:
这是生成的配置文件:
<?php
return [
/*
|--------------------------------------------------------------------------
| 只有在此注册过的邮件内容才可以被该依赖访问
|--------------------------------------------------------------------------
|
| You have to add the mailables including their dependencies
| in the following array. When asked for a mailable, the
| package will search it here for its definition.
|
| Eg: [ new OrderShipped(factory(Order::class)->create()) ]
|
*/
'mailables' => [],
/*
|--------------------------------------------------------------------------
| 定义查看邮件内容的 URL
|--------------------------------------------------------------------------
|
| This is the URL where you can view all the
| mailables registered above.
|
*/
'url' => 'mails',
/*
|--------------------------------------------------------------------------
| 可访问邮件内容的环境
|--------------------------------------------------------------------------
|
| If you don't want to use this package in production env
| at all, you can restrict that using this option
| rather than by using a middleware.
|
*/
'allowed_environments' => ['local', 'staging', 'testing'],
/*
|--------------------------------------------------------------------------
| 可应用于访问邮件内容 URL 的中间件
|--------------------------------------------------------------------------
|
| The value should be an array of fully qualified
| class names of the middleware classes.
|
| Eg: [Authenticate::class, CheckForMaintenanceMode::class]
| Don't forget to import the classes at the top!
|
*/
'middlewares' => [],
];
了解更多
你可以在 GitHub JoggApp/laravel-mail-viewer 访问源码和安装指引。如果您想了解有关创建可邮寄内容的更多信息,请参阅 Mail 文档的 [Generating Mailables部分](https://learnku.com/docs/laravel/5.7/mail#generati...)。
本文中的所有译文仅用于学习和交流目的,转载请务必注明文章译者、出处、和本文链接
我们的翻译工作遵照 CC 协议,如果我们的工作有侵犯到您的权益,请及时联系我们。
本帖已被设为精华帖!