2014-06-25 155 views
-1

我有我的数据库100000电子邮件,我要在第一包发送电子邮件的包发送多个电子邮件批次

形式

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); 

    } 
} 
+2

你还没有尝试过?向我们展示该代码。 – AkshayP

+2

你的问题是什么?你的代码不工作的方式是什么? – David

+0

发布一些代码,你的问题是什么? – WhiteLine

回答

0

此代码应该是在一个for循环和改变按照收件人:

$recipients = array(
    "[email protected]", 
    // 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);