Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork30
Laravel Exception Notifier will send an email of the error along with the stack trace to the chosen recipients. This Package includes all necessary traits, views, configs, and Mailers for email notifications upon your applications exceptions. You can customize who send to, cc to, bcc to, enable/disable, and custom subject or default subject base…
License
jeremykenedy/laravel-exception-notifier
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Laravel Exception Notifier | A Laravel 5, 6, 7, 8, 9 and 10 Exceptions Email NotificationPackage
Table of contents:
Laravel exception notifier will send an email of the error along with the stack trace to the chosen recipients.This Package includes all necessary traits, views, configs, and Mailers for email notifications upon your applications exceptions.You can customize who send to, cc to, bcc to, enable/disable, and custom subject or default subject based on environment.Built for Laravel 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 6, 7, 8, 9, and 10.
Get the errors and fix them before the client even reports them, that's why this exists!
From your projects root folder in terminal run:
Laravel 9-10 use:
composer require jeremykenedy/laravel-exception-notifier
Laravel 7-8 use:
composer require jeremykenedy/laravel-exception-notifier:2.2.0
Laravel 6 and below use:
composer require jeremykenedy/laravel-exception-notifier:1.2.0
Register the package
Laravel 5.5 and upUses package auto discovery feature, no need to edit the
config/app.phpfile.Laravel 5.4 and belowRegister the package with laravel in
config/app.phpunderproviderswith the following:
jeremykenedy\laravelexceptionnotifier\LaravelExceptionNotifier::class,
- Publish the packages view, mailer, and config files by running the following from your projects root folder:
php artisan vendor:publish --tag=laravelexceptionnotifier
NOTE: If upgrading to Laravel 9 or 10 from an older version of this package you will need to republish the assets with:
php artisan vendor:publish --force --tag=laravelexceptionnotifier
- In
App\Exceptions\Handler.phpinclude the additional following classes in the head:
useApp\Mail\ExceptionOccurred;useIlluminate\Support\Facades\Log;useIlluminate\Support\Facades\Mail;useThrowable;
useApp\Mail\ExceptionOccured;useIlluminate\Support\Facades\Log;useMail;useSymfony\Component\Debug\Exception\FlattenException;useSymfony\Component\Debug\ExceptionHandlerasSymfonyExceptionHandler;
- Update
App\Exceptions\Handler.php
/** * Sends an email upon exception. */publicfunctionsendEmail(Throwable$exception):void {try {$content = ['message' =>$exception->getMessage(),'file' =>$exception->getFile(),'line' =>$exception->getLine(),'trace' =>$exception->getTrace(),'url' =>request()->url(),'body' =>request()->all(),'ip' =>request()->ip(), ]; Mail::send(newExceptionOccurred($content)); }catch (Throwable$exception) { Log::error($exception); } }
/** * Register the exception handling callbacks for the application. */publicfunctionregister():void {$this->reportable(function (Throwable$e) {$enableEmailExceptions =config('exceptions.emailExceptionEnabled');if ($enableEmailExceptions) {$this->sendEmail($e); } }); }
/** * Report or log an exception. * * This is a great spot to send exceptions to Sentry, Bugsnag, etc. * * @param \Throwable $exception * * @return void */publicfunctionreport(Throwable$exception) {$enableEmailExceptions =config('exceptions.emailExceptionEnabled');if ($enableEmailExceptions ==='') {$enableEmailExceptions =config('exceptions.emailExceptionEnabledDefault'); }if ($enableEmailExceptions &&$this->shouldReport($exception)) {$this->sendEmail($exception); }parent::report($exception); }
/** * Sends an email upon exception. * * @param \Throwable $exception * * @return void */publicfunctionsendEmail(Throwable$exception) {try {$e = FlattenException::create($exception);$handler =newSymfonyExceptionHandler();$html =$handler->getHtml($e); Mail::send(newExceptionOccured($html)); }catch (Throwable$exception) { Log::error($exception); } }
Configure your email settings in the
.envfile.Add the following (optional) settings to your
.envfile and enter your settings:- Note: the defaults for these are located in
config/exception.php
- Note: the defaults for these are located in
EMAIL_EXCEPTION_ENABLED=false EMAIL_EXCEPTION_FROM="${MAIL_FROM_ADDRESS}" EMAIL_EXCEPTION_TO='email1@gmail.com, email2@gmail.com' EMAIL_EXCEPTION_CC='' EMAIL_EXCEPTION_BCC='' EMAIL_EXCEPTION_SUBJECT=''
└── laravel-exception-notifier ├── .gitignore ├── LICENSE ├── composer.json ├── readme.md └── src ├── .env.example ├── App │ ├── Mail │ │ └── ExceptionOccurred.php │ └── Traits │ └── ExceptionNotificationHandlerTrait.php ├── LaravelExceptionNotifier.php ├── config │ └── exceptions.php └── resources └── views └── emails └── exception.blade.php- Tree command can be installed using brew:
brew install tree - File tree generated using command
tree -a -I '.git|node_modules|vendor|storage|tests'
Laravel-Exception-Notifier | A Laravel Exceptions Email Notification Package is open-sourced software licensed under theMIT license
About
Laravel Exception Notifier will send an email of the error along with the stack trace to the chosen recipients. This Package includes all necessary traits, views, configs, and Mailers for email notifications upon your applications exceptions. You can customize who send to, cc to, bcc to, enable/disable, and custom subject or default subject base…
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors4
Uh oh!
There was an error while loading.Please reload this page.

