如何设计电子邮件系统?

时间:2021-07-25 16:13:30

I am working for a company that provides customer support to its clients. I am trying to design a system that would send emails automatically to clients when some event occurs. The system would consist of a backend part and a web interface part. The backend will handle the communication with a web interface (which will be only for internal use to change the email templates) and most important it will check some database tables and based on those results will send emails ... lots of them.

我在为一家为客户提供客户支持的公司工作。我正在尝试设计一个系统,当某些事件发生时,该系统会自动向客户端发送电子邮件。该系统将包括后端部分和Web界面部分。后端将处理与Web界面的通信(这将仅用于内部用于更改电子邮件模板),最重要的是它将检查一些数据库表,并根据这些结果将发送电子邮件......很多。

Now, I am wondering how can this be designed so it can be made scalable and provide the necessary performance as it will probably have to handle a few thousands emails per hours (this should be the peek). I am mostly interested about how would this kind of architecture should be thought in order to be easily scaled in the future if needed.

现在,我想知道如何设计它,以便它可以扩展并提供必要的性能,因为它可能每小时处理几千封电子邮件(这应该是偷看)。我最感兴趣的是如何考虑这种架构,以便在将来根据需要轻松扩展。

Python will be used on the backend with Postgres and probably whatever comes first between a Python web framework and GWT on the frontend (which seems the simplest task).

Python将在Postgres的后端使用,可能在Python Web框架和前端的GWT之间首先使用Python(这似乎是最简单的任务)。

5 个解决方案

#1


This is a real good candidate for using some off the shelf software. There are any number of open-source mailing list manager packages around; they already know how to do the mass mailings. It's not completely clear whether these mailings would go to the same set of people each time; if so, get any one of the regular mailing list programs.

这是使用一些现成软件的真正好选择。有许多开源邮件列表管理器包;他们已经知道如何进行群发邮件了。目前还不完全清楚这些邮件是否会每次都发送给同一组人;如果是这样,请获取任何一个常规邮件列表程序。

If not, the easy answer is

如果没有,简单的答案就是

$ mail address -s subject < file

once per mail.

每封邮件一次。

By the way, investigate the policies of whoever is upstream from you on the net. Some ISPs see lots of mails as probable spam, and may surprise you by cutting off or metering your internet access.

顺便说一句,在网上调查你上游的人的政策。一些ISP将大量邮件视为可能的垃圾邮件,并可能通过切断或计量您的互联网访问来让您感到惊讶。

#2


A few thousand emails per hour isn't really that much, as long as your outgoing mail server is willing to accept them in a timely manner.

只要您的外发邮件服务器愿意及时接受它们,每小时几千封电子邮件就不会那么多了。

I would send them using a local mta, like postfix, or exim (which would then send them through your outgoing relay if required). That service is then responsible for the mail queues, retries, bounces, etc. If your looking for more "mailing list" features, try adding mailman into the mix. It's written in python, and you've probably seen it, as it runs tons of internet mailing lists.

我会使用本地mta发送它们,如postfix或exim(如果需要,它会通过你的传出中继发送它们)。然后该服务负责邮件队列,重试,退回等。如果您正在寻找更多“邮件列表”功能,请尝试将mailman添加到组合中。它是用python编写的,你可能已经看过了,因为它运行了大量的互联网邮件列表。

#3


This sound to me, that you're trying to optimize for batch processing, where the heat doenst happen on the web interface but in the backend. This also sounds a job for a queuing architecture.

这听起来对你来说,你正在尝试优化批量处理,其中热量在网络界面上发生,但在后端。这对于排队架构来说也是一项工作。

Amazon offers queuing systems for instance if you really need massive scale. So you can add multiple machines on your side to deliver the messages as eMails. So you allow one machines only taking perhaps 100 messages from the queue at one time.

如果你真的需要大规模的话,亚马逊提供排队系统。因此,您可以添加多台计算机以将消息作为电子邮件发送。因此,您允许一台计算机一次只从队列中获取100条消息。

The pattern with eMail systems should be asychonous, so have a look at other asynchonous archictures if you dont like queues.

电子邮件系统的模式应该是不合理的,所以如果你不喜欢队列,那么看看其他异步的架构。

#4


You might want to check out Lamson, a state machine-based e-mail server written in Python that should be able to do what you have described. It's written by Zed Shaw, and he blogged about it recently here.

您可能想要查看Lamson,这是一个用Python编写的基于状态机的电子邮件服务器,应该能够执行您所描述的操作。它由Zed Shaw撰写,最近他在这里发表了博客文章。

#5


You might want to try Twisted Mail for implementing your own backend in pure Python.

您可能想尝试使用Twisted Mail在纯Python中实现自己的后端。

#1


This is a real good candidate for using some off the shelf software. There are any number of open-source mailing list manager packages around; they already know how to do the mass mailings. It's not completely clear whether these mailings would go to the same set of people each time; if so, get any one of the regular mailing list programs.

这是使用一些现成软件的真正好选择。有许多开源邮件列表管理器包;他们已经知道如何进行群发邮件了。目前还不完全清楚这些邮件是否会每次都发送给同一组人;如果是这样,请获取任何一个常规邮件列表程序。

If not, the easy answer is

如果没有,简单的答案就是

$ mail address -s subject < file

once per mail.

每封邮件一次。

By the way, investigate the policies of whoever is upstream from you on the net. Some ISPs see lots of mails as probable spam, and may surprise you by cutting off or metering your internet access.

顺便说一句,在网上调查你上游的人的政策。一些ISP将大量邮件视为可能的垃圾邮件,并可能通过切断或计量您的互联网访问来让您感到惊讶。

#2


A few thousand emails per hour isn't really that much, as long as your outgoing mail server is willing to accept them in a timely manner.

只要您的外发邮件服务器愿意及时接受它们,每小时几千封电子邮件就不会那么多了。

I would send them using a local mta, like postfix, or exim (which would then send them through your outgoing relay if required). That service is then responsible for the mail queues, retries, bounces, etc. If your looking for more "mailing list" features, try adding mailman into the mix. It's written in python, and you've probably seen it, as it runs tons of internet mailing lists.

我会使用本地mta发送它们,如postfix或exim(如果需要,它会通过你的传出中继发送它们)。然后该服务负责邮件队列,重试,退回等。如果您正在寻找更多“邮件列表”功能,请尝试将mailman添加到组合中。它是用python编写的,你可能已经看过了,因为它运行了大量的互联网邮件列表。

#3


This sound to me, that you're trying to optimize for batch processing, where the heat doenst happen on the web interface but in the backend. This also sounds a job for a queuing architecture.

这听起来对你来说,你正在尝试优化批量处理,其中热量在网络界面上发生,但在后端。这对于排队架构来说也是一项工作。

Amazon offers queuing systems for instance if you really need massive scale. So you can add multiple machines on your side to deliver the messages as eMails. So you allow one machines only taking perhaps 100 messages from the queue at one time.

如果你真的需要大规模的话,亚马逊提供排队系统。因此,您可以添加多台计算机以将消息作为电子邮件发送。因此,您允许一台计算机一次只从队列中获取100条消息。

The pattern with eMail systems should be asychonous, so have a look at other asynchonous archictures if you dont like queues.

电子邮件系统的模式应该是不合理的,所以如果你不喜欢队列,那么看看其他异步的架构。

#4


You might want to check out Lamson, a state machine-based e-mail server written in Python that should be able to do what you have described. It's written by Zed Shaw, and he blogged about it recently here.

您可能想要查看Lamson,这是一个用Python编写的基于状态机的电子邮件服务器,应该能够执行您所描述的操作。它由Zed Shaw撰写,最近他在这里发表了博客文章。

#5


You might want to try Twisted Mail for implementing your own backend in pure Python.

您可能想尝试使用Twisted Mail在纯Python中实现自己的后端。