Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make queueing error mails configureable #32

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ The package comes with `'silent' => true,` configuration by default, since you p

For sending emails when an exception occurs set `SNEAKER_SILENT=false` in your `.env` file.

#### should_queue

By default we send error mails via laravel queue. Set this to `false` if you want disable this behavior

```php
'should_queue' => env('SNEAKER_SHOULD_QUEUE', true),
```

or set `SNEAKER_SHOULD_QUEUE=false` in your `.env` file.

#### capture

Expand Down
10 changes: 10 additions & 0 deletions config/sneaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
|
*/
'silent' => env('SNEAKER_SILENT', true),

/*
|--------------------------------------------------------------------------
| Determine if we should queue the emails
|--------------------------------------------------------------------------
|
| Should we queue error traces?
|
*/
'should_queue' => env('SNEAKER_SHOULD_QUEUE', true),

/*
|--------------------------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions src/ExceptionMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class ExceptionMailer extends Mailable implements ShouldQueue
class ExceptionMailer extends Mailable
{
use Queueable, SerializesModels;

Expand Down
8 changes: 7 additions & 1 deletion src/Sneaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,19 @@ public function captureException(Exception $exception, $sneaking = false)
*/
private function capture($exception)
{
$shouldQueue = $this->config->get('sneaker.should_queue');
$recipients = $this->config->get('sneaker.to');

$subject = $this->handler->convertExceptionToString($exception);

$body = $this->handler->convertExceptionToHtml($exception);

$this->mailer->to($recipients)->send(new ExceptionMailer($subject, $body));
$mail = new ExceptionMailer($subject, $body);
if ($shouldQueue) {
$this->mailer->to($recipients)->queue($mail);
} else {
$this->mailer->to($recipients)->send($mail);
}
}

/**
Expand Down