Skip to content

bastinald/laravel-exception-emailer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Exception Emailer

This package will send an email any time an exception happens in your Laravel application. The email contains the exception message and a full stack trace. You can specify which email addresses to send to, as well as which environments the emails should be sent in.

Documentation

Installation

Require the package:

composer require bastinald/laravel-exception-emailer

Configure your .env MAIL settings, for example:

MAIL_MAILER=smtp
MAIL_HOST=localhost
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=info@laravel.test
MAIL_FROM_NAME="${APP_NAME}"

Dispatch the EmailException job in the Handler::register method:

namespace App\Exceptions;

use Bastinald\LaravelExceptionEmailer\Jobs\EmailException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;

class Handler extends ExceptionHandler
{
    public function register()
    {
        $this->reportable(function (Throwable $e) {
            EmailException::dispatch($e->getMessage(), $this->renderExceptionContent($e));
        });
    }
}

Publish the config file:

php artisan vendor:publish --tag=laravel-exception-emailer:config

Set the emails & environments in the published config file:

'emails' => 'admin@example.com',
'environments' => 'production',

Publishing Config

Customize the package configuration by publishing the config file:

php artisan vendor:publish --tag=laravel-exception-emailer:config

Now you can easily change things like the email addresses and exception environments.

About

Laravel exception message & stack trace emailer.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages