email sent by queuing
Mail::queue($mailTemplate, $model->getNotificationVars(), function($message) use ($user) {
$message->to($user->email, $user->name);
});
give the exception
````cmd
[2017-04-27 22:07:27] dev.ERROR: exception 'ErrorException' with message 'Serialization of closure failed: Serialization of 'Closure' is not allowed' in /Users/chris/Sites/asia/site/vendor/jeremeamia/SuperClosure/src/SerializableClosure.php:117
Stack trace:
````
415
What queue driver are you utilizing?
the default one, the 'sync'
Try passing something other than object to the closure
$email = $user->email;
$name = $user->name;
Mail::queue($mailTemplate, $model->getNotificationVars(), function($message) use ($email, $name) {
$message->to($email, $name);
});
I am getting a similar error after L5.5 upgrade. I have a plugin with this code:
// add the recipient data
$data['recipient'] = ['email' => $email, 'name' => $name];
/**
* email configuaration array
* @var array
*/
$email = [
'from_email' => Settings::get('from_email'),
'from_name' => Settings::get('from_name'),
'sender_email' => Settings::get('from_email'),
'sender_name' => Settings::get('from_name'),
'reply_to_email' => Settings::get('from_email'),
'reply_to_name' => Settings::get('from_name'),
'subject' => $mail->subject,
'to_email' => $email,
'to_name' => $name,
];
// send the email
if ($mail->delay) {
Mail::later($mail->delay, $mail->template, ['data' => $data], function($message) use ($email) {
$message->from($email['from_email'], $email['from_name']);
$message->replyTo($email['reply_to_email'], $email['reply_to_name']);
$message->subject($email['subject']);
$message->to($email['to_email'], $email['to_name']);
});
}
else {
Mail::send($mail->template, ['data' => $data], function($message) use ($email) {
$message->from($email['from_email'], $email['from_name']);
$message->replyTo($email['reply_to_email'], $email['reply_to_name']);
$message->subject($email['subject']);
$message->to($email['to_email'], $email['to_name']);
});
}
The contents of $email are all strings, so no objects. Any ideas? For the time being, I have changed Mail::queue to Mail::send, which works fine.
I am using the database queue connection at the moment but tried sync too with the same result. On Homestead dev environment and Mailgun sandbox setup.
Regards,
Mat
Fixed in Build 430+
Most helpful comment
Fixed in Build 430+