我们正在尝试使用 PHP Laravel 框架发送批量电子邮件(100k)。哪种方式是使用 Laravel 队列发送批量电子邮件的正确方式?
情况1。
//controller
public function runQueue(){
dispatch(new ShootEmailJob());
}
//job
public function handle(){
$emails = EmailList::get(['email']);
foreach($emails as $email){
Mail::to($email)->send();
}
}
案例 2。
//controller
public function runQueue(){
$emailList = EmailList::get(['email']);
foreach($emailList as $emailAddress){
dispatch(new ShootEmailJob($emailAddress->email));
}
}
//job
public function handle(){
Mail::to($emailAddress)->send(new ShootMail($emailAddress));
}
哪一个是正确的方法案例 1 或案例 2?