如何每周发送 100,000 封电子邮件?
如何使用 PHP 每周向 100,000 个用户发送一封电子邮件?这包括使用以下提供商发送给订阅者的邮件:
- AOL
- G-Mail
- Hotmail
- Yahoo
重要的是,所有电子邮件均应尽可能实际交付。显然,仅仅按照惯例发送邮件只会产生问题。
有没有 PHP 库可以让这件事变得更简单?
How can one send an email to 100,000 users on a weekly basis in PHP? This includes mail to subscribers using the following providers:
- AOL
- G-Mail
- Hotmail
- Yahoo
It is important that all e-mail actually be delivered, to the extent that it is possible. Obviously, just sending the mail conventionally would do nothing but create problems.
Is there a library for PHP that makes this simpler?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
简短回答:虽然从技术上讲,您自己每周发送 10 万封电子邮件是可能的,但最简单、最容易且最便宜的解决方案是外包给专门从事电子邮件发送的公司之一它(我确实说过“最便宜”:在尝试 DIY 时,您可以投入的开发时间(以及金钱)是没有限制的)。
长答案:如果您决定绝对想要自己做这件事,请做好迎接受伤世界的准备(毕竟,这是我们的电子邮件/电子邮件失败)正在谈论)。您需要:
mail()
本身就足够可怕了)令人惊讶的是,这就是简单的部分。困难的部分实际上是发送它:
)最重要的是,您必须管理其中的法律部分(各种联邦、州和地方法律;甚至一旦您将其发送到美国境外,还要处理不同的法律问题(注意:您无法确定是否[email protected] 居住在西南埃尔伯尼亚,该国拥有世界上最严厉的反垃圾邮件法) )。
我很确定我错过了这个九头蛇的几个头 - 你仍然确定要自己做吗?如果是这样,将会出现另一波浪潮,这一次只是发送电子邮件固有的烦人问题。 (您看,SMTP 是一种存储转发协议,这意味着您的电子邮件将在 Internet 上的许多 SMTP 服务器上进行传输,希望下一封邮件更接近最终收件人。基本上,电子邮件被发送到 SMTP 服务器,该服务器将其放入转发队列,当时间到来时,它会将其进一步转发到不同的 SMTP 服务器,直到到达给定域的 SMTP 服务器。 ,或在几分钟内,或几小时内,或几天内,或永远不会。)因此,您将看到以下问题 - 其中大多数可能发生在途中以及目的地:
不是您的朋友,
也不是您的朋友)
,并且你的工作就是解决问题并解决问题解决这个问题(提示:大多数情况下你不能)。经营合法群发邮件业务的人知道,最终你无法解决它,他们也无法解决它 - 并且他们对原因进行了充分研究、记录和概述(甚至可能作为 Powerpoint 演示文稿) - 配有声音和酷炫的过渡 - 您的老板可以理解),因为他们之前已经解释过这一点一百万次了。另外,对于真正可以解决的问题,他们非常清楚如何解决。
如果在完成这一切之后,您没有气馁并且仍然想这样做,那就继续吧:您甚至可能会找到更好的方法来做到这一点。只是要知道,前面的路并不容易——发送电子邮件是微不足道的,而送达它却很难。
Short answer: While it's technically possible to send 100k e-mails each week yourself, the simplest, easiest and cheapest solution is to outsource this to one of the companies that specialize in it (I did say "cheapest": there's no limit to the amount of development time (and therefore money) that you can sink into this when trying to DIY).
Long answer: If you decide that you absolutely want to do this yourself, prepare for a world of hurt (after all, this is e-mail/e-fail we're talking about). You'll need:
mail()
is horrible enough by itself)Surprisingly, that was the easy part. The hard part is actually sending it:
And to top it off, you'll have to manage the legal part of it (various federal, state, and local laws; and even different tangles of laws once you send outside the U.S. (note: you have no way of finding if [email protected] lives in Southwest Elbonia, the country with world's most draconian antispam laws)).
I'm pretty sure I missed a few heads of this hydra - are you still sure you want to do this yourself? If so, there'll be another wave, this time merely the annoying problems inherent in sending an e-mail. (You see, SMTP is a store-and-forward protocol, which means that your e-mail will be shuffled across many SMTP servers around the Internet, in the hope that the next one is a bit closer to the final recipient. Basically, the e-mail is sent to an SMTP server, which puts it into its forward queue; when time comes, it will forward it further to a different SMTP server, until it reaches the SMTP server for the given domain. This forward could happen immediately, or in a few minutes, or hours, or days, or never.) Thus, you'll see the following issues - most of which could happen en route as well as at the destination:
<blink>
is not your friend here, nor is<font color=...>
)and it'll be your job to troubleshoot and solve this (hint: you can't, mostly). The people who run a legit mass-mailing businesses know that in the end you can't solve it, and that they can't solve it either - and they have the reasons well researched, documented and outlined (maybe even as a Powerpoint presentation - complete with sounds and cool transitions - that your bosses can understand), as they've had to explain this a million times before. Plus, for the problems that are actually solvable, they know very well how to solve them.
If, after all this, you are not discouraged and still want to do this, go right ahead: it's even possible that you'll find a better way to do this. Just know that the road ahead won't be easy - sending e-mail is trivial, getting it delivered is hard.
人们推荐了 MailChimp,它是批量电子邮件的优秀供应商。如果您正在寻找优秀的交易电子邮件供应商,我也许可以提供帮助。
在过去 6 个月中,我们使用了四个不同的 SMTP 供应商,目的是找出最好的一个。
以下是我们发现的摘要...
AuthSMTP
邮戳
JangoSMTP
发送 com/" rel="nofollow">SendGrid
结论
SendGrid 是最好的,Postmark 位居第二。我们从来没有看到这两者在发送时间上有任何犹豫——在某些情况下,我们一次发送了数百封电子邮件——而且它们都具有最佳的投资回报率,因为它们具有可靠的功能集。
People have recommended MailChimp which is a good vendor for bulk email. If you're looking for a good vendor for transactional email, I might be able to help.
Over the past 6 months, we used four different SMTP vendors with the goal of figuring out which was the best one.
Here's a summary of what we found...
AuthSMTP
Postmark
JangoSMTP
SendGrid
Conclusion
SendGrid was the best with Postmark coming in second place. We never saw any hesitation in send times with either of those two - in some cases we sent several hundred emails at once - and they both have the best ROI, given a solid featureset.
以下是我最近在一个较大的系统上使用 PHP 所做的事情:
用户输入新闻通讯文本并选择收件人(生成一个查询以检索电子邮件地址供以后使用)。
将新闻通讯文本和收件人查询添加到名为 *email_queue* 的 mysql 表中的行
我创建了另一个脚本,其中作为 cron 作业每分钟运行一次。它使用 SwiftMailer 类。这个脚本很简单:
在工作时间内,发送优先级为 == 0 的所有电子邮件
下班后,按优先级发送其他电子邮件
根据主机设置,我现在可以使用标准的 swiftmailers 插件(例如 antiflood 和throttle...
并且
等等)对其进行节流。
我已经将其扩展到了这个伪代码之外,带有附件, 许多其他可配置的设置,但只要您的服务器设置正确以发送电子邮件,它就可以很好地工作。 (可能不会在共享主机上工作,但理论上它应该......) Swiftmailer 甚至有一个设置
,我现在用它来跟踪退回......
快乐的踪迹! (快乐的电子邮件?)
Here is what I did recently in PHP on one of my bigger systems:
User inputs newsletter text and selects the recipients (which generates a query to retrieve the email addresses for later).
Add the newsletter text and recipients query to a row in mysql table called *email_queue*
I created another script, which runs every minute as a cron job. It uses the SwiftMailer class. This script simply:
during business hours, sends all email with priority == 0
after hours, send other emails by priority
Depending on the hosts settings, I can now have it throttle using standard swiftmailers plugins like antiflood and throttle...
and
etc, etc..
I have expanded it way beyond this pseudocode, with attachments, and many other configurable settings, but it works very well as long as your server is setup correctly to send email. (Probably wont work on shared hosting, but in theory it should...) Swiftmailer even has a setting
Which I now use to track bounces...
Happy Trails! (Happy Emails?)