mozammil/laravel-message-interceptor

一个用于拦截电子邮件的Laravel包。特别适用于开发环境

v1.3.0 2021-11-02 20:19 UTC

This package is auto-updated.

Last update: 2022-07-30 22:07:11 UTC


README

Latest Version on Packagist Build Status Quality Score Software License

此Laravel包可以帮助拦截电子邮件,并将它们发送到本地环境中的其他接收者(或接收者)。

Laravel自带了一种在本地环境中拦截电子邮件的方式。然而,这个包提供了更多灵活性,例如在本地环境中对电子邮件和域名进行白名单管理,保留CCBCC收件人等。

这有望使电子邮件为中心的工作流程的测试体验对本地开发者来说更加轻松。

安装

通过Composer

$ composer require mozammil/laravel-message-interceptor --dev

由于包自动发现,这应该会自动注册您的ServiceProvider

配置

要发布配置文件,您应该执行以下操作

$ php artisan vendor:publish

配置文件将被复制到config/message-interceptor.php。它应该能给您一个关于此包可能性的概念。

<?php

return [

    /**
     * Whether or not the emails being sent should
     * be intercepted.
     */
    'enabled' => env('MESSAGE_INTERCEPTOR_ENABLED', false),

    /**
     * The intercepted emails will be sent
     * to this address instead. If the address
     * is not send, an exception will be thrown
     */
    'to' => [
        'address' => env('MESSAGE_INTERCEPTOR_ADDRESS', ''),
        'name' => env('MESSAGE_INTERCEPTOR_NAME', '')
    ],

    /**
     * By default, we will clear the recipients that are
     * cc'ed in the message. If you want to preserve the
     * cc'ed recipients, set this to true
     */
    'preserveCc' => env('MESSAGE_INTERCEPTOR_PRESERVE_CC', false),

    /**
     * By default, we will clear the recipients that are
     * bcc'ed in the message. If you want to preserve the
     * bcc'ed recipients, set this to true
     */
    'preserveBcc' => env('MESSAGE_INTERCEPTOR_PRESERVE_BCC', false),

    /**
     * The following addresses will also be CC'ed
     * when the email is intercepted and sent.
     */
    'cc' => [],

    /**
     * The following addresses will also be BCC'ed
     * when the email is intercepted and sent.
     */
    'bcc' => [],

    /**
     * Whitelisted email recipients.
     */
    'whitelist' => [
        /**
         * Email addresses in the list below will
         * not be filtered out
         */
        'emails' => [],

        /**
         * Email address matching the domain in
         * the list below will not be filtered out
         */
        'domains' => []
    ]
];

为了使包正常工作,以下配置在您的.env文件中是基本的。默认情况下,不会拦截任何电子邮件。

MESSAGE_INTERCEPTOR_ADDRESS=hello@example.com
MESSAGE_INTERCEPTOR_ENABLED=true

附加信息

每当拦截一封电子邮件时,也会触发一个Mozammil\LaravelMessageInterceptor\Events\MessageIntercepted::class事件。然后您可以从事件中检索原始的底层Swift_Message

变更日志

请参阅CHANGELOG以获取有关最近更改的更多信息。

测试

$ composer test

安全

如果您发现任何与安全相关的问题,请通过电子邮件hello@moz.im联系,而不是使用问题跟踪器。

致谢

许可

MIT许可(MIT)。有关更多信息,请参阅许可文件