https://github.com/bastinald/laravel-exception-emailer
Laravel exception message & stack trace emailer.
https://github.com/bastinald/laravel-exception-emailer
email emailer exception laravel
Last synced: about 2 months ago
JSON representation
Laravel exception message & stack trace emailer.
- Host: GitHub
- URL: https://github.com/bastinald/laravel-exception-emailer
- Owner: bastinald
- Created: 2021-08-02T06:25:35.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-09-11T03:08:53.000Z (almost 5 years ago)
- Last Synced: 2025-02-25T01:05:58.660Z (over 1 year ago)
- Topics: email, emailer, exception, laravel
- Language: PHP
- Homepage:
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# 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](#installation)
- [Publishing Config](#publishing-config)
## Installation
Require the package:
```console
composer require bastinald/laravel-exception-emailer
```
Configure your `.env` MAIL settings, for example:
```env
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:
```php
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:
```console
php artisan vendor:publish --tag=laravel-exception-emailer:config
```
Set the emails & environments in the published config file:
```php
'emails' => 'admin@example.com',
'environments' => 'production',
```
## Publishing Config
Customize the package configuration by publishing the config file:
```console
php artisan vendor:publish --tag=laravel-exception-emailer:config
```
Now you can easily change things like the email addresses and exception environments.