Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serialization of 'Closure' is not allowed when sending queued mails

Log::info('Sending email', array(
    'title' => $attributes['title'],
    'recipient' => $attributes['email']
));

Mail::queue('emails.welcome', $attributes, function($message) use ($attributes)
{
    $message
        ->to($attributes['email'])
        ->subject($attributes['title']);
});

The problem's with the closure being passed to Mail::queue. What's wrong? This is exactly the same with what's in the docs.

like image 512
Jürgen Paul Avatar asked Nov 12 '22 01:11

Jürgen Paul


1 Answers

Well, I assume that $attributes is something that you're trying to pass to e-mail view welcome. IF it is, so you'll need to put it in a array. In that case, should be something loike that:

Mail::queue('emails.welcome', array('attributes' => $attributes), function($message) use ($attributes)
{
    $message
        ->to($attributes['email'])
        ->subject($attributes['title']);
});

... this may work for you! :D

like image 156
Dennis Braga Avatar answered Nov 15 '22 11:11

Dennis Braga