使用PHP发送批量电子邮件 [英] Sending Bulk Emails using PHP
问题描述
当新用户加入时,我必须向网站上的所有用户发送邮件。
我的问题是脚本在发送大约400封邮件后停止执行。
我已经将set_time_limit设置为0.而且我发送10封邮件后还会给予睡眠(2)。
I have to send mails to all users in the site when a new user joins. My problem is the script stops execution after sending around 400 mails. I have set the set_time_limit to 0. And also I am giving sleep(2) after sending 10 mails.
可能是这个问题背后的原因。任何解决这个问题。有没有更好的方法发送大量电子邮件?
What may be the reason behind this issue.Any solution for this problem . Is there any better method to send bulk emails?
感谢提前
玫瑰
推荐答案
我们这样做的方式是在cron的帮助下。
The way we do it is with the help of cron.
我们(在我们公司)以50个地址的块分割用户列表。这些块放在数据库中的一个表中(将数据链接到电子邮件数据(标题,正文,..)。
We (at our company) split up the userlist in blocks of 50 addresses. These blocks are put in a table in the database (with data that links this block to the e-mail data (headers, body, ..).
通过cron .php文件,每5分钟左右触发一次,系统将抓取需要发送的数据库中的第一个可用的数据块,然后发送出去。
Through a cron.php file, which is triggered every 5 minutes or so, the system grabs the first available block in the database that needs to be sent and sends out the emails.
这篇关于使用PHP发送批量电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!