问题
I am using
Ubuntu
laravel 4.2
beanstalked
when i try to
php artisan queue:work
it returns
[ErrorException]
Insufficient data for unserializing - 1403 required, 218 present
mail function (confide package)
Mail::queueOn(
Config::get('confide::email_queue'),
Config::get('confide::email_account_confirmation'),
compact('user'),
function ($message) use ($user) {
$message
->to($user->email, $user->username)
->subject(Lang::get('confide::confide.email.account_confirmation.subject'));
}
);
回答1:
I came across this problem as well and I think I've got the solution.
When an email gets queued, Laravel needs to serialize all of the email's data so it can be recalled later on when the queue is being processed.
The problem is that when you try to serialize an instance of an Eloquent model ($user in this case) the serialized string will be too large to be stored in the queue.
To get around this, store the specific values you need in an array before calling Mail::queueOn and attach that array to the closure you pass as an argument to Mail::queueOn.
$data = array(
'email' => $user->email,
'username' => $user->username
);
Mail::queueOn(
Config::get('confide::email_queue'),
Config::get('confide::email_account_confirmation'),
compact('user'),
function ($message) use ($data) {
$message
->to($data['email'], $data['username'])
->subject(Lang::get('confide::confide.email.account_confirmation.subject'));
}
);
I found the solution while looking at this issue in GitHub
回答2:
We had it lately with the same question, but I've found another thing that is wrong:
Config::get('confide::email_queue'),
Config::get('confide::email_account_confirmation'),
and
(Lang::get('confide::confide.email.account_confirmation.subject'));
are not correct. There are no 2 :: to name the file, it is:
Config::get('confide.email_queue');
and so on for all the other declarations!
It is
filename.arraykey
来源:https://stackoverflow.com/questions/28142459/laravel-mail-queueing-insufficient-data-for-unserializing