我的数据库中有10万封电子邮件,我想以包裹的形式发送电子邮件
在第一个包中
send 1000 email
stop the process 10 second " sleep function ".
然后在第二个包中
send 1000 email
stop the process 10 second " sleep function "
这个我的代码其实不是发送电子邮件,而是通过“GCM”在移动设备上发送通知; 服务器超时在10分钟后结束,该过程在10分钟后结束,并且该过程未完成。
我的代码
$sql = mysql_query("SELECT * FROM noti_code ORDER BY noti_id desc ",$link);
while($row = mysql_fetch_array($sql)){
$gcmRegID = $row[noti_code];
$foo->message = $pushMessage = $_POST["message"];
$foo->link = $n_link = $_POST["n_link"];
$json = json_encode($foo);
//$result = mysql_query("insert into notifications(n_title,n_link,n_code)values('$json','$n_link','$gcmRegID')",$link);
$id = $_POST["regId"];
if (isset($gcmRegID) && isset($pushMessage)) {
$gcmRegIds = array($gcmRegID);
$message = array("m" => $json);
$pushStatus = sendPushNotificationToGCM($gcmRegIds, $message);
}
}
答案 0 :(得分:0)
此代码应位于for循环中并按照以下方式更改收件人:
$recipients = array(
"youremailaddress@yourdomain.com",
// more emails
);
$email_to = implode(',', $recipients); // your email address
$email_subject = "..."; // email subject line
$message = "..."; // body of the message
mail($email_to,$email_subject,$message);
sleep(10);