Skip to content

Package for Laravel that logs every mail sent and saves it to database as a log

License

Notifications You must be signed in to change notification settings

smajohusic/laravel-mail-logger

Repository files navigation

Laravel Mail Logger

Latest Version on Packagist Software License Build Status Total Downloads

Introduction

Mail logger has one purpose, save mail before they are sent from your app. This enables you to have backup of mail and a overview if something goes wrong.

This package listens to the MessageSending event fired from Mailer. The listener will dispatch a job, then save the needed form information, event, route and recipient to the database.

This package also supports auto deleting. You can define how long the the app should keep the logs by defining days in the config file.

Installation

Laravel 5.5 +

  1. composer require smajohusic/laravel-mail-logger

  2. Package is automatically discovered and registered via Laravel's automatic service provider registration.

Laravel 5.4 or earlier

  1. composer require smajohusic/laravel-mail-logger
  2. Add Smajo\MailLogger\MailLogServiceProvider::class to providers in app.php
  3. Execute command: php artisan vendor:publish --provider="Smajo\MailLogger\MailLogServiceProvider"
  4. Run: php artisan migrate to generate the mail-logger table

Requirements

Cron job

To enable auto-deleting you will need to set up a cron job that runs

php artisan schedule:run

Usage

mailLogger.php config

By default the auto-deleting is disabled. To enable it set

'enableAutoDeletion' => true,

You can set how long the logs should be stored in the database by giving amount in days.

'keepLogsForDays' => 30,

To make it easier to find mails, you can define all "to" fields your app uses in forms. This will then find the user e-mail in the request, and save it as the "sender" field.

'toEmailAddresses' => [
    'email',
    'e-mail',
    'to',
]

About

Package for Laravel that logs every mail sent and saves it to database as a log

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages