如何通过SMTP发送批量电子邮件而不建立每个电子邮件的连接? [英] How to send bulk emails through SMTP without establising a connection for every email?

查看:364
本文介绍了如何通过SMTP发送批量电子邮件而不建立每个电子邮件的连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个大型网站,向其用户发送各种电子邮件:时事通讯,忘记密码,用户创建的随机订阅等.门户网站非常大,我们每天需要发送数千封电子邮件.

We have a large website that sends out different kinds of emails to their users: newsletter, forgot password, random subscriptions created by users, etc.. The portal is pretty big and we need to send out thousands of emails per day.

现在的组织方式是,所有电子邮件都在数据库中排队,然后有一个cron脚本,该脚本每隔几分钟读取一次DB,并发送出X批电子邮件.该脚本本质上是一个遍历这X封电子邮件的for循环,并为它们中的每一个建立SMTP连接并发送电子邮件.但是,这会使服务器非常沉重,基本上在大多数时间,服务器正忙着一张一张地发送这些电子邮件.

The way it is organized now is that all emails are queued in database and then there is a cron script that reads DB every several minutes and sends out the batch of X emails. This script is essentially a for loop that goes through these X emails and for each of them establishes an SMTP connection and sends the emails. This however overloads the server pretty heavily, basically most of the time server is busy sending out these emails one by one.

我想知道是否有某种方法可以将这些排队的电子邮件批量发送到SMTP服务器.如果这涉及到某些专用软件,那就有问题了,我们可以设置自己的SMTP服务器(我们希望使用基于Linux/Unix的服务器).例如,某种可行的方法每天都在运行cron,将队列转换为XML文件并将该XML文件发送到SMTP服务器,然后SMTP服务器将对其进行解析并发送所有这些电子邮件.

I was wondering whether there is some way to send these queued emails to the SMTP server in batches. If this involves some specialized software, that's on problem, we can set up our own SMTP server (we'd prefer Linux/Unix based one). For instance something that would work is running a cron every day, convert that queue into an XML file and send that XML file to the SMTP server and then SMTP server would parse it and send out all these emails.

推荐答案

假定您的脚本在Linux或Unix服务器上运行:设置配置为连接缓存已启用.让您的脚本通过取件将其邮件提交到本地Postfix.

Assuming that your script is running on a Linux or Unix server: set up a local Postfix configured as a null client with connection cache enabled. Have your script submit its mails via pickup to the local Postfix.

这篇关于如何通过SMTP发送批量电子邮件而不建立每个电子邮件的连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆