joggapp / laravel-mail-viewer
此包已被废弃,不再维护。未建议替代包。
在一个地方查看所有可邮寄内容
v7.0.0
2020-09-10 18:38 UTC
Requires
- php: ^7.3
- illuminate/database: 7.*|8.*
- illuminate/routing: 7.*|8.*
- illuminate/support: 7.*|8.*
Requires (Dev)
- laravel/legacy-factories: ^1.0.4
- mockery/mockery: ^1.1
- orchestra/testbench: 5.*|6.*
- phpunit/phpunit: ^9.0
README
在一个地方查看所有可邮寄内容
设计和内容团队成员经常需要访问应用将发送给用户的电子邮件。这是一个相当简单的包,使得这成为可能,并试图最小化开发者的依赖。通过使用此包,您可以在一个地方查看所有可邮寄内容,并拥有可分享的URL来查看邮件,这使得团队协调更加顺畅。
安装
您可以通过composer使用以下命令安装此包:
composer require joggapp/laravel-mail-viewer
此包将自动注册自己。
您需要添加可邮寄内容并使用包的配置文件配置其他设置才能使用此包。请仔细阅读每个配置键的注释/描述并设置它们的值。您可以使用以下命令发布配置文件:
php artisan vendor:publish --provider="JoggApp\MailViewer\MailViewerServiceProvider"
这将创建一个名为 mailviewer.php
的配置文件,位于 config
目录中。以下是发布配置文件的内容
return [ /* |-------------------------------------------------------------------------- | Only the mailables registered here can be accessed using this package |-------------------------------------------------------------------------- | | 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. | | Add the mailable definition as shown below in the example. | The mailable class will be the key and the dependencies | of the mailable class will be defined in an array as well. | | The package will look for the equivalent factory if the | dependency is an eloquent model. So don't forget to | create those factories. If you want a specific state to | be used for your dependency you will have to pass an array | with 'class' and 'states' keys. The class key will have the | name of the dependency and states should contain an array of | factory states you want to apply to the factory, see the | MailWithDependencyStates example below. | | Please note that the factory times/count feature isn't | supported for the factories. | Eg: | What the package supports: factory(Order::class)->create(); | What the package doesn't support: factory(Order::class, 5)->create(); | | The package will try to resolve all other non-eloquent objects | using the Laravel's service container. | | Also, don't forget to import these classes at the top :) | | eg: | 'mailables' => [ | OrderShipped::class => [ | Order::class, | 'Personal thank you message', | ], | MailWithDependencyStates::class => [ | [ | 'class' => Order::class, | 'states' => ['state1', 'state2'] | ] | ], | MailWithNoDependency::class => [] | ] | */ 'mailables' => [], /* |-------------------------------------------------------------------------- | URL where you want to view the mails |-------------------------------------------------------------------------- | | This is the URL where you can view all the | mailables registered above. | */ 'url' => 'mails', /* |-------------------------------------------------------------------------- | The environments in which the url should be accessible |-------------------------------------------------------------------------- | | 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'], /* |-------------------------------------------------------------------------- | Middlewares that should be applied to the 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' => [], ];
如何使用
-
按照上述方式设置配置值后,您可以通过访问
/mails
路由(假设配置文件中的默认URL为 'mails')来查看所有可邮寄内容的列表。您可以根据需要将其修改为任何您想要的内容。 -
您还可以限制包应列出可邮寄内容的 环境。默认情况下,
allowed_environments
配置设置为允许 3 个环境:local
、staging
和testing
。您可以使用middlewares
配置进一步确保安全性。 -
默认视图
所有邮件列表 | 渲染特定邮件 |
---|---|
![]() |
![]() |
- 此包支持覆盖Laravel提供的包视图。您可以根据需要使用Laravel文档中的这些说明修改视图。
测试
您可以使用以下命令运行测试:
vendor/bin/phpunit
更新日志
有关最近更改的更多信息,请参阅 更新日志。
安全性
如果您发现任何与安全性相关的问题,请通过电子邮件 harish@jogg.co 联系,而不是使用问题跟踪器。
致谢
许可
MIT许可(MIT)。请参阅许可文件以获取更多信息。