Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在我的PHP脚本中添加暂停?_Php_Email - Fatal编程技术网

如何在我的PHP脚本中添加暂停?

如何在我的PHP脚本中添加暂停?,php,email,Php,Email,我有邮件发送脚本(使用PHP)。此脚本可能会发送太多电子邮件。。。。现在我需要这个脚本的限制。限制:当我们想要发送1000封电子邮件时,发送100封电子邮件后的脚本将休眠60秒。此伪代码解释: send 100 mails .... send ok. sleep 60s.(stop sending for 60s) send other 100 mails (100-200)... send ok. sleep 60s. (stop sending for 60s) send other 100

我有邮件发送脚本(使用PHP)。此脚本可能会发送太多电子邮件。。。。现在我需要这个脚本的限制。限制:当我们想要发送1000封电子邮件时,发送100封电子邮件后的脚本将休眠60秒。此伪代码解释:

send 100 mails ....
send ok.
sleep 60s.(stop sending for 60s)
send other 100 mails (100-200)...
send ok.
sleep 60s. (stop sending for 60s)
send other 100 mails (200-300)...
现在此脚本有两个限制:

$max_chars = 20000;
$max_sends = 100000;
但我还需要两个限制:

$sleep_time = 60s;
$sleep_after_send = 100;

你能帮我在这个脚本上加上这两个新的限制并编写类吗?

你可以使用php睡眠函数

for($i = 1 ;$i <= $max_sends ; $i++)
{
    // send email here and check status
    if($i % 100 == 0)
        sleep(60);  
}

for($i=1;$i嗯……不?我们不是来帮你做事情的。我们是来帮你解决编程问题的。如果你想让别人帮你做这件事,我建议你找个程序员并付钱给他们。小结:你可以用
100
交换
$sleep\u-after\u-send
值,也可以用
60
交换
$sleep\u-time