【问题标题】:Laravel Mail queues with Iron.io使用 Iron.io 的 Laravel 邮件队列
【发布时间】:2013-10-08 05:59:18
【问题描述】:

我的 Iron.io 推送队列订阅能够很好地工作,但由于某种原因不能使用邮件队列。在下面的代码中,我使用$data 数组中的电子邮件地址和用户名将作业推送到队列中。由于我不知道的原因,电子邮件地址和用户名没有传递给 Mail 功能。作业就在那里,发送失败。

FooController.php

<?php

$data = array(
    'email_address' => Input::get('email'),
    'username'      => Input::get('username'),
);

Queue::push('SendEmail@reserve', $data);

routes.php

<?php

// iron.io push queue path

Route::post('queue/push', function()
{
    return Queue::marshal();
});


class SendEmail
{
    public function reserve($job, $data)
    {
        Mail::send('emails.reserve', $data, function($message)
        {
            $message->to($data['email_address'], $data['username'])->subject($data['username'] . ', welcome to RockedIn!');
        });
        $job->delete();
    }
}
?>

【问题讨论】:

  • 我也有类似的问题,我可以看看你的 emails.reserve 查看吗?

标签: php laravel laravel-4 message-queue iron


【解决方案1】:

您需要将$data 传递给闭包。

public function reserve($job, $data)
{
    Mail::send('emails.reserve', $data, function($message) use ($data)
    {
        $message->to($data['email_address'], $data['username'])->subject($data['username'] . ', welcome to RockedIn!');
    });
    $job->delete();
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-04
    • 2013-09-14
    • 2016-07-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多