Skip to content

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.

License

Notifications You must be signed in to change notification settings

elegasoft/mailbox-router

Repository files navigation

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.

About

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.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages