adwiv / laravel-error-mailer
Report errors by mail while ignoring repeating ones.
v0.1.0
2021-08-04 21:51 UTC
Requires
- php: ^7.2 || ^8.0
- laravel/framework: >=6.0
This package is auto-updated.
Last update: 2025-03-05 05:38:42 UTC
README
Package to report laravel errors by email with throttling and deduplication.
Installation
- Require this package with composer using the following command:
composer require adwiv/laravel-error-mailer
- Run the migration to create the
error_logs
table.
php artisan migrate
- Add the following keys to .env file
# Required Key ERROR_MAILER_TO = "hello@example.com,admin@example.com" # Comma separated list of email addresses
# Optional Keys ERROR_MAILER_FROM = "errors@example.com" # Mail sender, if not defined defaults to config setting ERROR_MAILER_REPEAT_AFTER = 300 # Time in seconds for which same error will not be reported again ERROR_MAILER_HOURLY_LIMIT = 10 # Maximum number of error mails that will be sent in an hour
- Configure
config/logging.php
. The package automatically adds a logging channel namederror-mailer
.
The simplest way to use it is to add it the stack
channel.
'channels' => [ 'stack' => [ 'driver' => 'stack', 'channels' => ['single', 'error-mailer'], #<-- Add here 'ignore_exceptions' => false, ], ... ],
Thats all. Any errors should now be reported to all the email addresses listed in ERROR_MAILER_TO
environment option.
Troubleshooting
If mails are not being recieived, please check:
- Mail sending is configured correctly and you are able to send other mails without any issues.
- The
ERROR_MAILER_TO
variable is defined in .env file and has valid email addresses (without spaces) - The mail queue is being processed correctly
- Check the laravel.log for any reported issues.