Laravel 5.3向队列中的多个用户发送电子邮件提醒

时间:2016-12-07 06:11:30

标签: php laravel email queue

我需要向队列中的用户发送提醒电子邮件

目前我有

UserController.php

public function postSendUsersPaymentRequest(Request $request){
    $users_ids     = $request->get('user_checked');        
    dispatch(new SendPaymentRequestEmail($users_ids)); 
    return response()->json(['code' => 200], 200);
}

\应用\作业\ SendPaymentRequestEmail.php

public function handle(UserRepository $userRepo)
{
    $users =   $userRepo->getUserInfoDetails(3,1,1)->whereIn('user_id',$this->users_ids);
    foreach($users as $user){
        $this->emailPaymentRequest($user);
    }
}

private function emailPaymentRequest($user){
    Mail::queue($this->email_vew, ['user' => $user], function ($m) use ($user) {             
        $from         = Config::get('mail.from');
        $project_name = Config::get('app.project_name');                         
        $m->from('fromemail', $project_name);
        $m->to('toemail', $user->name)->subject('Payment Request');                                                    
    });       
}

但电子邮件无需排队即可发送。

感谢您提前提供任何帮助。

1 个答案:

答案 0 :(得分:0)

QUEUE_DRIVER=database添加到 .env 文件中。