elegasoft/mailbox-router

使用 beyondcode/laravel-mailbox 注册和管理邮箱的样板

v1.3 2023-10-20 22:10 UTC

This package is auto-updated.

Last update: 2024-09-21 00:19:24 UTC


README

此包通过提供在服务提供者之外的路由文件中注册邮件处理程序的简单语法扩展了 beyondcode/laravel-mail

安装

您可以通过 composer 安装此包

composer require elegasoft/mailbox-router

用法

首先将路由文件存档发布到 routes/mail.php

php artisan mailboxes:install

(可选) 生成一个处理路由的邮箱(例如 App\Mailboxes\MyMailbox

php artisan make:mailbox MyMailbox

然后定义处理传入邮件的邮箱

// routes/mail.php

return [
    /*
     * Map emails sent from a specific address to a class which
     * will be invoked to process the incoming email message.
     *
     * For example: 'from@test.org' => ExampleMailbox::class
     */

    'from' =>  [
            'example@example.org'  => MyMailbox::class,
            'example2@example.org' => MyMailbox::class,
        ],

    /*
     * Map emails sent to a specific address to a class which
     * will be invoked to process the incoming email message.
     *
     * For example: 'to@test.org' => ExampleMailbox::class
     */

    'to' => [],

    /*
     * Map emails cc'd to a specific address to a class which
     * will be invoked to process the incoming email message.
     *
     * For example: 'cc@test.org' => ExampleMailbox::class
     */

    'cc' => [],

    /*
     * Map emails containing a specific subject to a class which
     * will be invoked to process the incoming email message.
     *
     * For example: 'This Subject' => ExampleMailbox::class
     */

    'subject' => [],

    /*
     * Only when an email does not match any of the preceding
     * invoke this class to catch the email for processing.
     *
     * For example: ExampleFallbackMailbox::class,
     */

    'fallback' => ExampleFallbackMailbox::class,

    /*
     * Regardless of when an email matches any of the preceding
     * always invoke this class to process the email message.
     *
     * For example: ExampleCatchAllMailbox::class,
     */

    'catchAll' => ExampleCatchAllMailbox::class,
];

MailboxRouterServiceProvider::class 将自动绑定每个邮件路由并调用处理与注册匹配的电子邮件所需的类或回调。

已知不兼容性

您不能使用 beyondcode/laravel-mailbox 文档 中定义的 正则表达式约束

测试

composer test

更新日志

有关最近更改的更多信息,请参阅 更新日志

贡献

有关详细信息,请参阅 贡献指南

安全

如果您发现任何安全问题,请通过电子邮件 jason@elegasoft.com 而不是使用问题跟踪器。

许可

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

Laravel 包样板

此包是使用 Laravel 包样板 生成的。