如何使用定时器批量发送电子邮件?

发布于 2024-11-02 22:58:19 字数 291 浏览 1 评论 0原文

假设我的数据库中有 200 个用户,并且当前托管在共享主机上。我想向他们发送简讯,并且每 5 分钟仅发送 10 封电子邮件。

我将使用 phpmailer 发送新闻通讯。问题..

  • 使用现有数据库发送新闻通讯而不将其导出到第三方服务的好概念是什么?
  • 确保脚本不会同时发送重复的新闻通讯的关键是什么?
  • 实现我的目标的良好做法是什么?

让我知道

Let's say I have 200 users in my database and currently host on shared hosting. I want to send a newsletter to them and send only 10 emails every 5 minutes.

I'll send the newsletter using phpmailer. Questions..

  • What is the good concept to send a newsletter using existing database without export it to 3rd party services?
  • What is the key to make sure script will not send duplicate newsletter in same time?
  • What is the good practice to achieve my goal.

Let me know

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

空城仅有旧梦在 2024-11-09 22:58:19

您应该只使用具有良好 API 的 3d 方服务。从长远来看,工作量会少得多。

您没有考虑过退回邮件处理、取消订阅、域密钥、避免黑名单等等。

最好的情况是您的邮件最终会进入垃圾邮件箱。

最糟糕的是,您的 IP 将被禁止,您的帐户将因发送未经请求的电子邮件而被终止(您的 ISP 不会关心他们是否真的注册了)。

You should just use a 3d party service with a good API. It will be much less work in the long run.

You haven't thought about bounce handling, unsubscribe, domain keys, avoiding blacklists and more.

At best your messages will end up in the junk mail box.

At worse your IP will be banned and your account terminated for sending unsolicted email (Your ISP won't care if they actually signed up for it).

心意如水 2024-11-09 22:58:19

设置一个任务,从数据库中选择固定数量的未发送新闻通讯(我会删除已发送的新闻通讯或将它们标记为已发送,或将它们移动到另一个表)。在您的情况下,您显然希望每 5 分钟发送 10 封电子邮件,因此将任务设置为获取 10 封电子邮件并发送它们。然后设置一个 cron 并让它每五分钟运行一次...如果您只计划每周发送一次/两次电子邮件,那么可能有一个更优雅的解决方案。您可以使用 sleep 命令执行一些 while 循环,但这并不是特别有效的资源效率......我只想采用上面的方法 - 它可能是最灵活的强力解决方案,并且您的主机不会真正注意到,因为它仍然会相对较快。

Set up a task to select a fixed number of un-sent newsletters from the database (I would either delete sent newsletters or mark them as sent, or move them to another table). In your case you're obviously wanting to send 10 every 5 minutes, so set the task to fetch 10 emails, and send them. Then set up a cron and have it run every five minutes... There's probably a more elegant solution though if you're only ever planning on sending out the emails once / twice a week. You could do some while loops with a sleep command but thats not particularly resource efficient.... I would just go with the above - its probably the most flexible brute force solution, and your host won't really notice as it'll still be relatively quick.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文