Search code examples
phplaravelnotificationslumen

Laravel Lumen Return 500 Error When Sending Notification


I tried to send a verification email in Laravel/Lumen using this piece of code.

 public function sendEmailVerificationNotification() {
        try {
          $this->notify(new VerifyEmail);
        } catch(\Exception $e) {
          print_r($e->getMessage());
        }
      }

The problem is I always get error 500. The cause of the error seems to be $this->notify() function because when I comment that line, the service runs perfectly. I put the try-catch block to find out the reason of the failure but I got nothing. Instead of getting the cause, I only get the error 500 display. Error 500

I am confused because I cannot find the root cause. Do any of you have experienced the same thing? Or maybe you can suggest to me a way to debug it so that I can get the information about the root cause.


Solution

  • First off all I guess your .env file has APP_DEBUG set to false. In order to get the actual error stack setting that it true will help you a lot. Use APP_DEBUG = false in production servers and apps not in your development.

    Coming back to the point, I don't know if its valid but sometimes I faced this situation due to the reason that I have configured all my queued jobs to be pushed to Redis and sometimes in my local machine I forget to turn Redis service ON.

    If this is applicable to you also please check that.

    Note: This may not be applicable to you.