A simple package to send test emails from artisan commands in Laravel applications. Ideal for checking mail and queue configurations without any setup.
You can install the package via composer:
composer require resohead/laravel-test-mail
The package will automatically register itself.
Optionally publish the config file to enable presets:
php artisan vendor:publish --provider="Resohead\LaravelTestMail\LaravelTestMailServiceProvider" --tag="config"
To send a test email run the following artisan command:
php artisan mail:test
By default this will:
- send to the 'from' address defined in your mail config,
- use your default mail driver,
- synchronous processing
Alternatively you have four other options in the command signature:
- set the email address,
- change the mail driver,
- enable for queuing (and set the queue name)
- change the queue connection
- select a preset
Changing the mail driver and running through a queue might require the queue worker to be started/reset.
php artisan mail:test [email protected]
php artisan mail:test [email protected] --queue
php artisan mail:test --driver=log
php artisan mail:test --stack=emails
There is no need to set the --queue flag when using the stack argument
php artisan mail:test --connection=sqs
There is no need to set the --queue flag when using the connection argument
php artisan mail:test [email protected] --driver=smtp --connection=redis --stack=emails
You might need to start the your queue if using the connection option, for example
php artisan queue:work sqs --queue:emails
You can also configure presets to group command line options. The values defined in each preset will be merged with the command line values and your default mail and queue configuration.
'presets' => [
'example1' => [
'recipient' => '[email protected]',
'queue' => true
],
'example2' => [
'driver' => 'log',
'stack' => 'emails'
],
'example3' => [
'recipient' => env('EMAIL_TO', '[email protected]'),
'driver' => 'smtp',
'connection' => 'redis',
'stack' => 'notifications'
],
]
Set a specific email address and use default queue:
php artisan mail:test --preset=example1
// php artisan mail:test [email protected] --queue
Use the log mail driver and emails queue
php artisan mail:test --preset=example2
// php artisan mail:test --driver=log --stack=emails
Use the log mail driver and emails queue
php artisan mail:test --preset=example3
// php artisan mail:test [email protected] --driver=smtp --connection=redis --stack=notifications
This is a simple package designed to quickly trigger an email to check your configuration.
If you want to check what an email looks like in the browser use the Laravel documentation to render mailables (available since Laravel 5.5).
If you need a package to send a mailable using fake data try using Spatie's laravel-mailable-test package.
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.