Serialization of 'Closure' is not allowed in Laravel 5.3 Email Queue

前端 未结 3 643
Happy的楠姐
Happy的楠姐 2021-01-07 22:51

I am willing to send email to list of email address using queue. Without using queue my code is working fine but with queue it\'s showing following error:

相关标签:
3条回答
  • 2021-01-07 23:05

    You cannot serialize request. Only eloquent model can be serialized and unserialzed. See here: https://laravel.com/docs/5.2/queues#writing-job-classes

    You should use $request->all() instead of $request. Since Request is treated as closure.

    0 讨论(0)
  • 2021-01-07 23:07

    Try removing this line from constructor:

    $this->message = new Message();
    

    and, in the handle directly initialise it.

    $student = $this->data;
    $arrStudent = (new Message())->getEmailAddressList($student);
    Mail::to($arrStudent)->send(new MessageSent($student));
    
    0 讨论(0)
  • 2021-01-07 23:20

    It happened to me in Laravel 5.6. I just added this:

    use Illuminate\Support\Facades\Mail;
    

    And everything worked well.

    0 讨论(0)
提交回复
热议问题