使用php mail()函数循环发送+ -200封电子邮件 [英] Sending +-200 emails using php mail() function in a loop
问题描述
注意:值得注意的是 mail()函数不适用于 循环发送大量电子邮件. 此功能打开和关闭SMTP 每个电子邮件的套接字,不是 非常有效. 来源:PHP手册
Note: It is worth noting that the mail() function is not suitable for larger volumes of email in a loop. This function opens and closes an SMTP socket for each email, which is not very efficient. Source: PHP manual
什么是大笔交易? 100还是1000 ?? 我可以安全地使其循环200次而没有很多问题吗? (我无法安装梨)
What are larger volumes? A 100 or a 1000?? Can I safely make it loop 200 times without much problems? (I can't install pear)
推荐答案
尽管它比自定义邮件程序或为处理该问题而适当设置的程序包要慢得多,但您可以将其循环200次而几乎没有什么问题.
You can loop it 200 times with few problems I would imagine, although it will be much slower than a custom mailer or a package set up properly to handle that.
最终结果取决于许多因素.您需要确保的主要事情是使用 set_time_limit()给予脚本足够的时间做工作.将工作卸载到cron脚本提供服务的某种队列中也可以使您的工作变得更轻松,因为长时间运行PHP脚本会带来其他资源问题.
The end result depends on many factors. The main thing you'll want to make sure of is that you use set_time_limit() to give the script enough time to do the work. Offloading the work into some kind of queue that's serviced by a cron script can make life easier on you as well, as keeping PHP scripts running for a long time will bring up other resource problems.
过去,我曾经使用PHP的邮件功能和安装了Exim的RedHat服务器向订户通讯发送约50,000封电子邮件.使用我运行的自定义脚本需要4到6个小时.没有什么有效的方法,但是它可以完成工作.
Back in the day, I used to send about 50,000 emails to a subscriber newsletter using PHP's mail function and a RedHat server with Exim installed. It would take 4-6 hours with the custom script I had running. There was nothing efficient about it, but it did the job.
这篇关于使用php mail()函数循环发送+ -200封电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!