我有一个功能,允许我向我的数据库中的每个成员发送一封电子邮件。我的邮件列表已经增长,我现在在将大约700封电子邮件添加到队列后超时。有没有办法让我的循环更有效率我是否需要增加超时限制?
以下是我的功能:
这是循环:
foreach($members as $member){
if (!empty($member->contact_email)){
$mData = array(
'from' => $from,
'fromName' => $fromName,
'email' => $member->contact_email,
'name' => $member->contact_firstName,
'body' => $body,
'subject' => $subject,
'meta' => $meta
);
$mail = array(
'email' => $member->contact_email,
'name' => $member->contact_firstName,
'body' => $body,
'subject' => $subject,
);
Mail::queue('emails.memberMessage', $mail, function($message) use ($mData)
{
$message->from($mData['from'], $mData['fromName']);
$message->to($mData['email'], $mData['name'])->subject($mData['subject']);
$message->getHeaders()->addTextHeader('X-MC-Metadata', $mData['meta']);
});
$status = SUCCESS;
}
}