发送排队邮件时不允许序列化"关闭"

Jür*_*aul 5 laravel laravel-4

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']);
});
Run Code Online (Sandbox Code Playgroud)

传递给闭包的问题是什么Mail::queue.怎么了?这与文档中的内容完全相同.

Den*_*aga 1

好吧,我假设$attributes正在尝试将其传递给电子邮件视图welcome。如果是,那么您需要将其放入数组中。在这种情况下,应该是这样的:

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

...这可能对你有用!:D