The Design and content team members often need access to the emails your app will be sending out to the users. This is a fairly simple package that makes it possible and tries to minimize developer dependency. By using this package, you can have a dedicated route to view all your mailables at a single place. Having shareable URLs to view the mails makes the team co-ordination more smooth.
You can install this package via composer using this command:
composer require joggapp/laravel-mail-viewer
The package will automatically register itself.
You will have to add the mailables and configure the other settings using the package's config file in order to to use this package. You can publish the config file with:
php artisan vendor:publish --provider="JoggApp\MailViewer\MailViewerServiceProvider"
This will create the package's config file called mailviewer.php
in the config
directory. These are the contents of the published config file:
return [
/*
|--------------------------------------------------------------------------
| Only the mailables registered here can be accesed using this package
|--------------------------------------------------------------------------
|
| You have to add the mailables including their dependencies
| in the following array. When asked for a mailable, the
| package will search it here for its defination.
|
| Eg: [ new OrderShipped(factory(Order::class)->create()) ]
|
*/
'mailables' => [],
/*
|--------------------------------------------------------------------------
| URL where you want to view the mails
|--------------------------------------------------------------------------
|
| This is the URL where you can view all the
| mailables registered above.
|
*/
'url' => 'mails',
/*
|--------------------------------------------------------------------------
| The environments in which the url should be accesible
|--------------------------------------------------------------------------
|
| If you don't want to use this package in production env
| at all, you can restrict that using this option
| rather than by using a middleware.
|
*/
'allowed_environments' => ['local', 'staging', 'testing'],
/*
|--------------------------------------------------------------------------
| Middlewares that should be applied to the URL
|--------------------------------------------------------------------------
|
| The value should be an array of fully qualified
| class names of the middlware classes.
|
| Eg: [Authenticate::class, CheckForMaintenanceMode::class]
| Don't forget to import the classes at the top!
|
*/
'middlewares' => [],
];
-
After setting up the config values as described above, you can see the list of all mailables by visiting the
/mails
route (considering the default url is 'mails' in the config file). You can modify it to whatever you want as per your needs. -
You can also restrict the environments the package should list the mailables in. By default, the
allowed_environments
config is set to allow 3 environments:local
,staging
&testing
. You can further secure it using themiddlewares
config. -
Default view:
List of all mails | A particular mail rendered |
---|---|
- This package supports the option of overriding the package views that Laravel provides. You can modify the view using these instructions from the Larvel docs, as per your needs.
You can run the tests with:
vendor/bin/phpunit
Please see CHANGELOG for more information what has changed recently.
If you discover any security related issues, please email harish@jogg.co instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.