anlutro / laravel-4-smart-errors

Smarter error handling for Laravel 4
65 stars 13 forks source link

Mail is not being sent due to mailer not bound #20

Closed hackel closed 9 years ago

hackel commented 9 years ago

I am getting your custom error views, but no email. I started debugging your code, and found that the problem lies in ErrorHandler::shouldSendEmail(). In my application, $this->app->bound('mailer') == false. I'm not sure why this is, since I routinely use email in my app with the Laravel Mailer functions and haven't had an issue. I'm loading your service provider last (after Mail), could that make a difference here?

Edit: commenting out that if/return block on line 242 allows the mail to be sent successfully.

hackel commented 9 years ago

The problem is that mailer is registered as a deferred service. Changing the check to:

if (!($this->app->bound('mailer') || $this->app->isDeferredService('mailer')))

Fixed the problem for me. Not sure if we still need app->bound, but I left it in just in case. Also, I'm still on Laravel 4.1, not sure if that might be causing an incompatibility here as well.

anlutro commented 9 years ago

Hello,

You're entirely correct - this problem was fixed (by me) in 4.2. Checking for isDeferredService as well should work in both versions, though. I'll be looking into it.

anlutro commented 9 years ago

Fixed in 2.4.9