我正在使用向30K用户发送电子邮件的系统,我实现了队列,并且在本地主机上以有限的用户运行良好,但是实时不发送邮件...我该怎么办?< / p>
我发送邮件的工作:
class NewestInWeekForSubscription implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public function handle()
{
foreach (User::cursor() as $user) {
try{
if ($user->hasTriedLaminorPlus()) {
if ($user->email) {
Mail::to($user)->queue(new \App\Mail\NewestInWeekForSubscription($user));
dump('email sent to ' . $user->email);
}
}
}
catch (\Exception $e){
dump('email not send to ' . $user->email);
continue;
}
}
}
我的邮件结构:
class NewestInWeekForSubscription extends Mailable
{
use Queueable, SerializesModels;
public function __construct(User $user,) {
$this->user = $user;
}
public function build()
{
return $this->subject(trans('views.email.marketing.title'))
->view('emails.newest-week-for-subscription');
}
}
答案 0 :(得分:0)
我认为最好使用bcc()
函数而不是foreach
。