Python smtplib 比 PHP mail() 慢

发布于 2024-10-03 16:05:24 字数 324 浏览 0 评论 0原文

我将一些 PHP 应用程序移植到了 Python。

令我惊讶的是,时事通讯模块(10 万+ 订阅者)的性能下降了十倍。我预计使用 SMTP 会产生一些开销(我认为 PHP 直接调用 sendmail),但没有那么多。

如何加快 Python 邮件传递速度?

编辑:对于任何挖掘这个问题的人,我使用 celery 与 8 个工作人员在后台发送电子邮件解决了这个问题,如下设置我每小时可以发送大约 200K 条消息。 Celery 与 django 和 AMQP 岩石集成得很好。

I ported some PHP applications to Python.

To my surprise, performance dropped by ten times in the newsletter module (100k+ subscribers). I was expecting some overhead for using SMTP (I think PHP calls sendmail directly), but not that much.

How can I speedup Pythons mail delivery?

EDITED: For anyone digging this question, I solved this using celery with 8 workers to delivery e-mail in background, with this setup I can deliver about 200K messages per hour. Celery integrates very well wit django, and AMQP rocks.

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

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

发布评论

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

评论(1

同展鸳鸯锦 2024-10-10 16:05:24

PHP 的 mail() 确实使用了 sendmail。您可以在 Python 中通过 subprocess

PHP's mail() does indeed use sendmail. You can do the same thing in Python by invoking it via subprocess.

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