PHP 群发电子邮件最佳实践? (PHPMailer + Gmail)
我正在考虑如何处理从我的网络应用程序发送大量电子邮件,以及是否有任何最佳实践。 StackOverflow 已经将其标记为“主观”,在某种程度上可能是这样,但我需要知道实现该系统的最成功的方法,或者是否存在任何标准化方法。
在我的 web 应用程序中,有一些用户是 1 到 10,000 个用户组的组长。该用户必须能够通过我的系统通过电子邮件向所有这些用户发送消息。因此,我的系统负责向每个组长的个人用户发送最多 10,000 封电子邮件。
据我所知,GMail 中向个人发送邮件没有速率限制(尽管最多有 500 个收件人)。
现在,我当前的设置是:
- 当通过系统发送消息时,它会进入电子邮件队列。
- cron 脚本每隔几分钟从队列中抓取消息,并发送这些电子邮件。
- 所有电子邮件均通过 GMail 的 SMTP 服务器进行。
- 实际执行邮件发送的应用程序是 PHPMailer。
随着用户群的增长,这种设置可能还不够。我的问题是:
- 我应该使用本地 SMTP 服务器吗?
- 我应该在本地计算机上使用邮件二进制文件吗?在这种情况下,我可能可以完全跳过队列?
- 有没有一种可以接受的方法来做到这一点?
谢谢!
I'm thinking about how to handle sending large amounts of email from my web applications, and whether there are any best practices for doing so. StackOverflow is already labeling this as 'subjective', which it may be to an extent, but I need to know the most successful way to implement this system, or whether any standardized approach exists.
In my webapp, there are users who are heads of groups of 1 to 10,000 users. This user must be able to email send a message to all of these users through my system. Therefore, my system is responsible for sending up to 10,000 emails to individual users for each group head.
As far as I can tell, there is no rate limit in GMail for sending messages to individuals (although there is a 500 recipient max).
Right now, my current setup is:
- When a message is sent through the system, it enters an email queue.
- A cron script grabs messages from the queue every few minutes, and sends out those emails.
- All email is taking place through GMail's SMTP server.
- The actual application doing the mailing is PHPMailer.
This setup, as the user base grows, will probably not suffice. The questions I have are:
- Should I be using a local SMTP server instead?
- Should I use a mail binary on the local machine instead? I this case, I could probably skip the queue altogether?
- Is there an accepted way to do this?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
谷歌应用程序引擎
我会在谷歌应用程序引擎(python)中编写这个,因为:
PHP
如果我用 PHP 实现它,我会
你可以在 php/apache/webpage 的
这是页面您将从中向用户发送消息。在此页面中,您将通过在以下行中进行编码来向 beanstalkd 发送消息:
您必须使用 put 命令将消息放入消息队列中
从后台长期运行的 PHP 脚本:
代码看起来像这样:
就像我说的那样PHP 和 Google 应用程序引擎都可以实现,但我会选择应用程序引擎,因为它更容易实现。
Google App Engine
I would write this in Google app engine (python) because:
PHP
If I would implement it in PHP I would
from php/apache/webpage
This is the page from which you will sent messages out to user. From this page you will sent message to beanstalkd by coding something in the lines of this:
You have to put messages in message queue using put command
From long running PHP script in background:
The code would look something like this:
Like I am saying it is possible with both PHP and Google app engine but I would go for app engine because it is easier to implement.
由于每天的电子邮件数量“高达”10,000 封,我不会依赖 GMail(或任何其他)SMTP。并不是说他们不能处理,显然他们可以处理更多。但他们可能不想这么做。
在我看来,拥有本地 SMTP 服务器是正确的方法:
With an email count as "high" as 10.000 a day, I wouldn't rely on GMail (or any other) SMTP. Not that they can't handle it, obviously they can handle A LOT more. But they possibly don't want to.
Having a local SMTP server is IMO the way to go :
Gmail 和 Google Apps 限制您每天最多发送 500 封电子邮件。我不确定这如何与最多 500 个收件人相结合,但如果您想发送 10,000 封电子邮件,您可能需要寻找另一个邮件服务器。我个人使用本地服务器或 ISP 或数据中心的 SMTP。
如果您要发送那么多电子邮件,我建议使用队列,这样用户就不会坐在那里等待电子邮件发送。
Gmail and Google Apps limits you to around 500 emails a day. I'm not sure how that combines with the 500 recipient max, but if you want to send 10 000 emails you'll probably want to find another mail server. I personally use a local server or the ISP or datacenter's SMTP.
If you are sending that many emails, I would recommend using the queue so the user's isn't sitting there waiting for the email to be sent.
请务必小心,不要将您的域作为垃圾邮件域列入黑名单。如果确实如此,您的大部分电子邮件、支持、销售等都会被屏蔽。这反过来可能会带来非常昂贵的费用。
您可能想使用 AWeber 之类的服务。它们不仅可以处理如此大量的电子邮件,而且还可以为您提供比您自己实现的更多的指标。
Be very careful that your domain doesn't get blacklisted as a spam domain. If it does, you can expect most of your emails to be blocked, support, sales, etc. Which could in turn be very expensive.
You may instead want to use a service like AWeber. Not only are they setup to handle these amounts of emails, but they can probably give you more metrics than you can implement on your own.
我不确定它是否在任何地方发布,但根据经验,我可以告诉您,如果您开始一次发送数百封邮件,Gmail 将会冻结您的帐户十五分钟左右。这件事上周发生在我身上。我认为您应该托管自己的 SMTP 服务器。使用 mail() 函数通常会将您的邮件放入某人的垃圾邮件文件夹中。
I'm not sure if it's publishe anywhere, but from experience I can tell you that Gmail will put a fifteen minute or so freeze on your account if you start sending hundreds of messages at a time. This happened to me last week. I think you should host your own SMTP server. Using the mail() function often will put your mail in someone's spam folder.
只需在本地计算机或同一 LAN 上的计算机上安装 Postfix 即可获得最大访问速度。确保它从外部牢固固定,并且可以从内部快速访问。
然后编写 PHP 脚本以将电子邮件直接注入到 Postfix 队列中。这将大大提高邮件传递的处理速度。
Just install Postfix on the local machine, or a machine on the same LAN for maximum access speeds. Make sure it is well secured from the outside, and quickly accessible from the inside.
Then code your PHP script to directly inject the emails to the Postfix queue. That shall dramatically increase the processing speed of mail delivery.