douquan1015 2009-08-27 20:43
浏览 43
已采纳

在PHP中调用Mail()之间休眠

How would i send an email, to say 3000 recipients - with a Max 500 emails / hours on my dedicated IP? So far my thought is to send each email every 9 seconds, this would come to about 450 emails an hour... but how could i do this?

My plan for the sending of the emails would be the following...

$emails = ARRAY OF EMAILS, MYSQL RESULT
for($emails){
mail($subject,$row[email],$headers);
}

This wont work, wrong kind of statement but this concept anyway....

  • 写回答

5条回答 默认 最新

  • duan0708676887 2009-08-27 20:49
    关注

    What I would do is :

    • create a PHP script that is launched via cron once per hour
    • this script only sends 450 e-mails, at its own speed
    • when the 450 mails are sent, the script dies
    • and some time later, it is re-launched, by cron, to send 450 other mails.

    The trick is : you have to know which mails where already sent.
    Ordering the mails by id in your DB, or something like that, and using limit, would be OK, I suppose

    If you want to sleep for a while between mails, use the sleep function ; something between 2 and 5 seconds would probably be OK, to be sure you script the chunk of 450 mails is finished before the script is re-launched by cron.


    And, thinking about it :

    • You should put some logging stuff in place : if someone complains, saying he received 10 emails, it could help you find out why.
    • I wouldn't use the mail function : there are plenty of other possibilities, using libraries that are well-tested and provide lots of functionnalities, already developped : don't re-invent the wheel ;-)

    Here are a couple of libraries I can think about :

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办