【发布时间】:2013-11-05 06:33:15
【问题描述】:
所以,我在一个免费的网络主机 3owl.com 上运行。我知道免费主机与付费主机相比很糟糕,但它是暂时的。无论如何,我有 90 个用户需要向他们发送电子邮件。
问题:
I cannot send them at a speed of more than 1 every 4 seconds.
I must not run the while loop for more than 40 seconds at a time.
所以,我需要帮助弄清楚如何分段发送电子邮件。
Send email 1
4 second break
Send email 2
4 second break
Send email 3
4 second break
Send email 4
4 second break
Send email 5
4 second break
Send email 6
4 second break
Send email 7
4 second break
Send email 8
4 second break
Send email 9
4 second break
Send email 10
---------------
STOP SCRIPT in a way that doesnt load the website? for 10 seconds
---------------
continue with the next 10
这甚至可能吗? 也许是某种列出用户的复选框系统,您可以检查您希望将其通过电子邮件发送给谁......
这是我当前的代码
mail_users($_POST['subject'], $_POST['content']);
这个函数看起来像这样:
function mail_users($subject, $body) {
$query = mysql_query("SELECT `email`, `first_name` FROM `users` WHERE `allow_email` = 1");
while (($row = mysql_fetch_assoc($query)) !== false) {
email($row['email'], $subject, "Hello ". $row['first_name'] . ",\n\n" . $body);
sleep(4);
}
}
我非常需要帮助。也许复选框需要一些javascript
【问题讨论】:
-
您是否有理由需要在网页中使用代码来执行此操作?您是否考虑过将您的电子邮件列表导出到 Outlook 或 ConstantContact?
-
你有 shell 访问权限吗?将 sendmail 替换为 qmail,您可以排队发送。它在我必须调节时间间隔内发送的消息数量的相同情况下对我有用。不是为了做广告,而是 Digital Ocean 以每月 5 美元的价格提供非常好的 Lampp 托管服务。