logikool/laravel-email-logger

Keep track in your database of all emails sent from within your application.

1.0 2018-03-03 16:50 UTC

This package is not auto-updated.

Last update: 2024-05-12 03:12:04 UTC


README

This package provides a simple logging mechanism for all emails that are sent in your application. It uses Laravel's built in events which the logger listens to and creates a database entry from a Swift_Message object.

Installation

  1. Install via composer
composer require logikool/laravel-email-logger
  1. If you are not using package auto-discovery, add the service provider to your app.php configuration file.
Logikool\LaravelEmailLogger\LaravelEmailLoggerServiceProvider::class,
  1. Publish configuration and migration files
php artisan vendor:publish --provider="Logikool\LaravelEmailLogger\LaravelEmailLoggerServiceProvider"
  1. Run the migration
php artisan migrate

Configuration

Laravel Email Logger has it's own Eloquent model and Event Listeners, but if you need to, you can change those in your email-logger.php.

return [

  'model' => \Logikool\LaravelEmailLogger\Models\EmailLog::class,

  'listeners' => [
    'MessageSending' => \Logikool\LaravelEmailLogger\Listeners\MessageSending::class,
    'MessageSent' => \Logikool\LaravelEmailLogger\Listeners\MessageSent::class,
  ]

];

MessageSending and MessageSent are Laravel's built-in events and you can use your own listeners by providing a fully qualified class name.

EmailLog is a model which you can replace or extend if you need to.