你好,我创建了一个 Laravel 队列作业来发送邮件
public function handle() {
foreach($this->emails as $value) {
$to = $value->email;
$subject = $this->data['subject'];
$this->data['t_firstname'] = $value->firstname;
$this->data['t_lastname'] = $value->lastname;
if (view()->exists('mail.requirement_to_tutor')) {
$view = view('mail.requirement_to_tutor',$this->data);
$html = $view->render();
}
file_put_contents('test.txt', 'test database');
$body = $html;
$headers = "From: " . $this->data['from'] . "\r\nReply-To: " . $this->data['from'] . "";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset: utf8\r\n";
mail($to, $subject, $body, $headers);
}
}
我还从仓库推送数据
$obj = (new SendStudentRequirement($TutorsbyCity,$data));
$this->dispatch($obj);
但它不作为后台运行,该函数正在等待队列完成,请帮帮我
默认情况下sync使用驱动程序。您应该将其更改为中列出的另一个驱动程序config/queue.php
在您的中查找以下行.env
文件并调整为不同的驱动程序:
QUEUE_DRIVER=sync
Laravel - 文档 - 队列 https://laravel.com/docs/5.2/queues
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)