joggapp/laravel-mail-viewer

此包已废弃,不再维护。没有建议的替代包。

在一个地方查看所有可邮寄邮件

v7.0.0 2020-09-10 18:38 UTC

README

在一个地方查看所有可邮寄邮件

Latest Version Total Downloads

设计和内容团队通常需要访问应用将发送给用户的邮件。这是一个相当简单的包,使得这成为可能,并试图最小化开发者的依赖。通过使用这个包,您可以有一个专门的路由来在一个地方查看所有可邮寄邮件,共享的URL查看邮件使团队协作更加顺畅。

安装

您可以使用以下命令通过composer安装此包

composer require joggapp/laravel-mail-viewer

包将自动注册自己。

为了使用此包,您需要添加可邮寄邮件并使用包的配置文件配置其他设置。请仔细阅读每个配置键的注释/描述并设置它们的值。您可以使用以下命令发布配置文件

php artisan vendor:publish --provider="JoggApp\MailViewer\MailViewerServiceProvider"

这将在config目录中创建名为mailviewer.php的配置文件。以下是发布配置文件的内容

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个环境:localstagingtesting。您可以使用middlewares配置进一步保护它。

  • 默认视图

所有邮件列表 渲染的特定邮件

测试

您可以使用以下命令运行测试

vendor/bin/phpunit

更新日志

请参阅更新日志了解最近有哪些变化。

安全

如果您发现任何安全相关的问题,请通过harish@jogg.co发送电子邮件,而不是使用问题跟踪器。

致谢

许可证

MIT许可证(MIT)。请参阅许可证文件了解更多信息。