在 php 中使用 PEAR::Mail 发送批量邮件?
我是 PEAR::Mail 的新手,我正在寻找可以教我如何发送批量邮件(10K+ 电子邮件)的教程。 “在 php 中使用 mail() 效率不高,因为它打开和关闭 smtp 套接字”,这是我从互联网资源中读到的内容(现在找不到链接,grrr)。
因此,我正在考虑手动执行此操作并使用可用于 PHP 的邮件库,并且我发现了这个 PEAR:Mail。在PEAR网站本身上,有“发送多个收件人”简单教程,所有收件人将被插入到一个数组中,然后发送。这是发送 10k++ 邮件的方式吗?我记得有一个叫做“邮件队列”的东西,但真的不知道如何在 PEAR:Mail 中使用它,有人可以帮助我吗?
我不认为 Facebook 会使用 for 循环来发送批量电子邮件(通知),对吗? (嗯,这就是我的想法)
I am new to PEAR::Mail, and I am looking for a tutorial that can teach me how to send bulk mails(10K+ emails). "Using mail() in php is not efficient, as its open and close the smtp sockets", this is what I read from internet sources (could not find link now, grrr).
Thus, I am thinking of doing it manually and using mail library that are available for PHP, and I found this PEAR:Mail. On the PEAR site itself, there is "Sending Multiple Recipients" simple tutorial, all recipients will be inserted into an array and then send. Is this the way of sending 10k++ emails? I remember something called "mail queue", but really dont how to use it in PEAR:Mail, can anyone help me?
I dont think Facebook will use for loop to send bulk emails (notifications) right? (well, this is what I thought)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
批量电子邮件不仅仅是您实现发件人所用的语言。就 rich 建议的库而言,您将考虑使用 SMTP 中继来排队和限制您的邮件。
正如我当我为公司编写群发邮件时发现的那样任何批量邮件发送者面临的主要问题是邮件发送到以太坊的速度以及如何管理已列入灰名单或其他内容的邮件的重试。
因此,第一,您需要一个可靠的 SMTP 服务器来运行邮件发送作业。您还需要某种方法来限制服务并对其进行监控。在运行 IIS 并连接到相当大的管道的标准 Windows 服务器上,我们每 15 分钟可以清除 5k 封邮件。如果您希望在 48 小时内实现所有这些,那么您就会被催促。
事实上,推送数据的速度存在硬性限制,而且 ISP 等还施加了进一步的人为限制。如果您不希望作业以蜗牛般的速度运行,那么限制、正确的 DNS 记录等就变得至关重要。我可以将 10k 封邮件推送出去(邮件大小约为 50kb,这样可以让您对吞吐量有更进一步的了解)的最短时间是半小时,我们拥有顶级的套件和与大型网络的连接。分配管道支持我们。
在我们公司成立之初,他们通常通过我们当地的宽带将东西邮寄出去,大约需要 12-14 个小时才能发送 7000 封邮件。所以你必须明白物理资源非常重要。
此外,您将不可避免地最终得到每 10k 中至少大约 50 封邮件,而这些邮件无法首次投递。其中大约有 10 个永远不会去任何地方。重试队列中这些邮件的存在可能会对后续批次邮件的传送产生一定的拖累影响,虽然影响很小但很重要。
此外,您不能只是将 10k 邮件文件放入任何服务器并期望它对此完全满意。通过实验我们发现,每三分钟发送 1000 封邮件可以为我们提供最佳的队列发送比率。您的里程数将根据您的硬件而有所不同。
坦率地说,您在这个阶段最不用担心的是软件库的选择。
There's more to bulk email than which language you implement your sender in. As far as the library suggested by rich goes you would be looking at using an SMTP relay to queue and throttle your mails.
As I discovered when I wrote the mass mailer for my company the major problem any bulk mailer faces is the speed at which mails can be punted out into the ether and how it manages retries for mails that have been graylisted or whatever.
So number one you need a good solid SMTP server which can run the mailout job. You will also want some way to throttle the service and monitor it. On a standard Windows Server running IIS and connected to a reasonably large pipe we can clear 5k mails every 15 minutes. If you're looking to implement all that in 48 hours you're going to be pushed.
The fact is there are hard limits to how fast you can push data and further artificial limits imposed by ISPs and so on and so forth. This makes throttling, correct DNS records and the like absolutely vital if you don't want the job to run at snail's pace. The minimum time I could push 10k mails out the door (and the mails are about 50kb in size so that gives you a further idea on throughput) is half an hour and we've got top of the line kit and a connection into a vast distribution pipe backing us up.
In the early days of our company when they used to mail the stuff out from our local broadband it took about 12-14 hours to send 7000 mails. So you've got to understand that physical resources are really important.
Also you will inevitably end up with a minimum of about 50 mails per 10k that just won't deliver first time out. And about 10 of those are not going anywhere ever. The existence of these mails in the retry queue can have a bit of a drag effect on the delivery of further batches of mail, it's minimal but significant.
Also you can't just bang 10k mail files into any server and expect it to be entirely happy about it. We've found through experimentation that dripping 1k mails every three minutes gives us the optimal queue to send ratio. Your mileage will vary depending on your hardware.
Frankly, your choice of software library is the least of your worries at this stage.
对电子邮件要真的非常小心,关于垃圾邮件和数据保护,有很多事情需要考虑。对于 Pear,似乎没有什么有用的文档,尽管这可能对您有帮助:
http: //www.phpmaniac.net/wiki/index.php/Pear_Mail
不过,也许您最好使用“Campaign Monitor”之类的工具,特别是如果您时间不够的话。
Be reallyREALLY careful with email stuff, there is a hell of a lot to think about with reguards to spam and data protection. With Pear, there is little useful documentation anywhere it seems, though this may help you:
http://www.phpmaniac.net/wiki/index.php/Pear_Mail
Though maybe you may be better off using something like Campaign Monitor, espescially if you are short on time.