laravelflare / mail-debug
Installs: 11 571
Dependents: 0
Suggesters: 0
Security: 0
Stars: 13
Watchers: 4
Forks: 1
Open Issues: 0
Requires (Dev)
- mockery/mockery: ~0.9.1
- orchestra/testbench: ~3.1
- phpunit/phpunit: ~4.0
README
This package is designed to help you easily preview and debug emails sent by your Laravel application in the browser. It provides a pop-up email preview on the subsequent page request after an email has been triggered by your application.
It is based off of which is extremely helpful for more persistent logging and previewing (including .eml files).
Quick Start Guide
Install the package into your project using composer:
composer require "laravelflare/mail-debug"
Add the Mail Debug Service Provider to your Applications Service Providers list:
LaravelFlare\MailDebug\MailDebugServiceProvider::class,
Publish the configuration file using:
php artisan vendor:publish
In your .env file, set your mail driver to debug
:
MAIL_DRIVER=debug
How It Works
By registering your mail driver as debug
, when an email is 'sent' Mail Transport stores the contents of the email to the application storage folder. It then sets the filename of the stored email into the Session.
On the next request (page load) the Mail Debug middleware will check the Session to determine if an email is available to be previewed. If it is, it will trigger the email to be displayed in a browser pop up window.
Note: You may need to allow pop-ups in your browser to see the preview emails.
Configuration Options
Path
This is the Mail Preview Storage Path to store mail preview files in. By default this is /storage/email-previews, but you can use whatever you like!
Lifetime
This is the amount of time to store the preview files for (in minutes). By default this is one minute but can be increased if you would like a certain level of persistence.
Improvements Required
-
Implement Tests
-
Currently this only works for the last mail sent in a request. If your request cycle sends several emails, only the final email will be displayed on the subsequent page request pop-up.