Skip to content
This repository has been archived by the owner on Jan 7, 2021. It is now read-only.
/ laravel-mailman Public archive

"Mailman" mail driver for Laravel 5.2+ which allows email delivery to be restricted by environment and recipients.

License

Notifications You must be signed in to change notification settings

qodeboy/laravel-mailman

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Travis Packagist Packagist StyleCI Scrutinizer

"Mailman" mail driver for Laravel 5.2+ which allows email delivery to be restricted by environment but allowed for specific recipients.

Installation

Begin by installing the package through Composer. Run the following command in your terminal:

composer require qodeboy/laravel-mailman "5.2.*"

Once composer is done, add the package service provider in the providers array in config/app.php:

Qodeboy\Mailman\MailManServiceProvider::class,

Then publish the config file:

php artisan vendor:publish --provider="Qodeboy\Mailman\MailmanServiceProvider"

Change MAIL_DRIVER to mailman in your .env file:

MAIL_DRIVER=mailman

Finally, run migrations:

php artisan migrate

How it works

For every email sent this package will:

  • Check if current application environment is allowed to send emails.
  • If environment if denied, check if all of recipients are in the exception list.
  • Passe email through only if environment is allowed to send emails, or all of the recipients are in exception list.
  • Log email to database or filesystem (if configured to do so) along with it's status (allowed/denied).
  • Send email through configured "delivery" driver.

Configuration

Delivery driver

Delivery driver used to send emails which passed all checks is configured in mailman.delivery.driver option:

/*
 * Driver which will be used to deliver email if email
 * is allowed to send out.
 *
 * Allowed any driver as accepted by mail.driver core
 * config parameter.
 */
'driver' => 'log',

You can use any driver name here (except of mailman) which Laravel is aware of.

Allowed environments

To configure which environments are allowed to send emails, check mailman.delivery.environments option:

/*
 * List of environments which allowed to send emails.
 */
'environments' => [
    'production'
],

Each environment added here is allowed to send emails.

Allowed recipients

If you want to lock down environment but still allow some recipients to receive emails, add those addresses to mailman.delivery.recipients list:

/*
 * List of recipients which are allowed to receive
 * emails even if environment forbids email delivery.
 */
'recipients' => [],

Logging

By default this package will log every email which tries to go through into database. This is configured in mailman.log option:

/*
 * Configuration for email logging.
 */
'log' => [
    
    /*
     * Whatever email logging should be enabled or not.
     */
    'enabled' => true,

    /*
     * Storage to use for email log.
     * Possible values are 'database', 'filesystem'.
     */
    'storage' => 'database',
],

If you want to change log storage to simple filesystem log, change mailman.log.storage option to filesystem. Filesystem path where to store logs is explained below. If you want to completely turn off logging, just change mailman.delivery.enabled to false.

Logging storage

To customize where each logging driver is storing email logs, check mailman.storage option:

/*
 * Storage configuration.
 */
'storage' => [
    /*
     * Configuration for which database table should
     * be used for email logging.
     */
    'database' => [
        'table' => 'mailman_messages',
    ],

    /*
     * Configuration for where to store logged email messages.
     * Relative to the storage_path().
     */
    'filesystem' => [
        'path' => 'mailman'
    ]
],

About

"Mailman" mail driver for Laravel 5.2+ which allows email delivery to be restricted by environment and recipients.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages