简体   繁体   English

Laravel Mail与Iron.io排队

[英]Laravel Mail queues with Iron.io

I have been able to get my Iron.io push queue subscription to work great, but not with mail queues for some reason. 我已经能够使Iron.io推送队列订阅正常运行,但是由于某些原因不能与邮件队列一起使用。 In the code below I am pushing a job onto the queue with an email address and username in the $data array. 在下面的代码中,我使用$data数组中的电子邮件地址和用户名将作业推送到队列中。 For reasons unknown to me, the email address and username are not getting passed to the Mail function. 由于我不知道的原因,电子邮件地址和用户名未传递到邮件功能。 The job just sits there, failing to send. 作业只是坐在那里,无法发送。

FooController.php FooController.php

<?php

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

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

routes.php 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();
    }
}
?>

You need to pass $data to the closure. 您需要将$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();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM