The-Monkeys-and-MAUD/laravel-error-emailer

Not receiving mails

Closed this issue · 4 comments

What is incorrect over here, that is it not sending e-mails:
Path:
app / config / packages / themonkeys / error-emailer / config.php

<?php
return array(
    /*
    |--------------------------------------------------------------------------
    | Enable emailing errors
    |--------------------------------------------------------------------------
    |
    | Should we email error traces?
    |
    */
    'enabled' => true,

    /*
    |--------------------------------------------------------------------------
    | Skip emailing errors for some HTTP status codes
    |--------------------------------------------------------------------------
    |
    | For which HTTP status codes should we NOT send error emails?
    |
    */
    'disabledStatusCodes' => array(
        '404' => true,
    ),

    /*
    |--------------------------------------------------------------------------
    | Error email recipients
    |--------------------------------------------------------------------------
    |
    | Email stack traces to these addresses.
    |
    | For a single recipient, the format can just be
    |   'to' => array('address' => 'you@domain.com', 'name' => 'Your Name'),
    |
    | For multiple recipients, just specify an array of those:
    |   'to' => array(
    |       array('address' => 'you@domain.com', 'name' => 'Your Name'),
    |       array('address' => 'me@domain.com', 'name' => 'My Name'),
    |   ),
    |
    */

    'to' => [
           ['address' => 'me@apple.cc', 'name' => 'xx'],
           ['address' => 'foo@bar.biz', 'name' => 'xx'],
    ],
);

And / app / config / packages / themonkeys / error-emailer / local / config.php
with enabled to false:

<?php
return array(
    /*
    |--------------------------------------------------------------------------
    | Enable emailing errors
    |--------------------------------------------------------------------------
    |
    | Should we email error traces?
    |
    */
    'enabled' => false, 

    /*
    |--------------------------------------------------------------------------
    | Skip emailing errors for some HTTP status codes
    |--------------------------------------------------------------------------
    |
    | For which HTTP status codes should we NOT send error emails?
    |
    */
    'disabledStatusCodes' => array(
        '404' => true,
    ),

    /*
    |--------------------------------------------------------------------------
    | Error email recipients
    |--------------------------------------------------------------------------
    |
    | Email stack traces to these addresses.
    |
    | For a single recipient, the format can just be
    |   'to' => array('address' => 'you@domain.com', 'name' => 'Your Name'),
    |
    | For multiple recipients, just specify an array of those:
    |   'to' => array(
    |       array('address' => 'you@domain.com', 'name' => 'Your Name'),
    |       array('address' => 'me@domain.com', 'name' => 'My Name'),
    |   ),
    |
    */

    'to' => array('address' => null, 'name' => null),
);

That looks fine to me. Is your application is definitely detecting an environment other than local? And do you have a default from address configured in app/config/mail.php? And you added the provider to app/config/app.php too?
Try setting a breakpoint at ErrorEmailerServiceProvider.php:37 and seeing whether it gets hit.

same error here, but on my start/global.php file i did this:
App::error(function(Exception $exception, $code)
{

// NEW STUFFS
Log::error($exception);

// assumes you have app/views/errors/401.blade.php, etc
$view = "common/errors/general";

// add data that you want to pass to the view
$data = array('code'=>$code);

switch ($code) {
   case 401:
   return Response::view($view, $data, $code);

   case 403:
   return Response::view($view, $data, $code);

   case 404:
   return Response::view($view, $data, $code);

   case 500:
   return Response::view($view, $data, $code);

}
});

I had the same problem, it's because you already handle most errors with App::error. I added this in my App::error to send the error mails:

        // email non 404 errors
        if (!App::runningInConsole() &&
            Config::get('error-emailer::enabled') &&
            !Config::get('error-emailer::disabledStatusCodes.'.$code)) {
            ErrorEmailer::sendException($exception);
        }

I've updated the README to cover this issue - look for the Error handler precedence section. In summary, change App::error to App::pushError in your app/start/global.php file to make your error handler run last instead of first. Then @jonasva you won't need that extra code you added.