LaravelPackages.net
Acme Inc.
Toggle sidebar
elegasoft/mailbox-router

A Boilerplate for registering and managing Mailboxes with beyondcode/laravel-mailbox

55
1
v1.4.1
About elegasoft/mailbox-router

elegasoft/mailbox-router is a Laravel package for a boilerplate for registering and managing mailboxes with beyondcode/laravel-mailbox. It currently has 1 GitHub stars and 55 downloads on Packagist (latest version v1.4.1). Install it with composer require elegasoft/mailbox-router. Discover more Laravel packages by elegasoft or browse all Laravel packages to compare alternatives.

Last updated

Laravel Mailbox Route Registration

This package extends beyondcode/laravel-mail by providing a simple syntax to register mail handlers in a routes file which is outside of a service provider.

Installation

You can install the package via composer:

composer require elegasoft/mailbox-router

Usage

First publish the route file stub to routes/mail.php:

php artisan mailboxes:install

(Optional) generate a mailbox to handle a route (i.e. App\Mailboxes\MyMailbox):

php artisan make:mailbox MyMailbox

Then define mailboxes to handle incoming mail:

// 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: '[email protected]' => ExampleMailbox::class
     */

    'from' =>  [
            '[email protected]'  => MyMailbox::class,
            '[email protected]' => MyMailbox::class,
        ],

    /*
     * Map emails sent to a specific address to a class which
     * will be invoked to process the incoming email message.
     *
     * For example: '[email protected]' => 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: '[email protected]' => 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,
];

The MailboxRouterServiceProvider::class will automatically bind each of the mail routes and invoke the classes or callbacks which when required to process an email which matches the registration.

Known Incompatibilities

You cannot use Regular Expression Contraints as define in the beyondcode/laravel-mailbox docs.


Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

Comments