本文介绍了MTA 究竟是做什么的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题 让我开始思考,现在我意识到我对 MTA 的内部原理一无所知.

This question got me thinking, and I now realize that I don't know anything about the internals of MTAs.

MTA 究竟是做什么的?SMTP 协议之后的一切对我来说都像是黑魔法.假设我想编写一个简单的 MTA(或 MDA)来发送电子邮件,什么会我需要学习/做吗?

What exactly does an MTA do? Everything after the SMTP protocol seems like dark magic to me. Let's say that I wanted to code a minimalistic MTA (or MDA) just for sending emails, what would I need to learn/do?

编辑:我实际上并不打算编写 MTA,我只是想了解它的内部运作方式.

Edit: I don't actually plan on writing an MTA, I just want to understand how it works internally.

推荐答案

--- 在不知何故注意到你谈到可能编写 MTA 之后进行编辑---

--- edit after somehow noticing you talked about possibly writing a MTA ---

要编写 MTA,您需要打开一个服务器套接字.当有人连接时,您需要根据 SMTP 协议在该套接字上发送和接收文本 (ascii) 数据.SMTP 非常健谈,因此您可以期待几轮通信.

To write a MTA, you need to open a server socket. When someone connects, you need to send and receive text (ascii) data on that socket in compliance with the SMTP protocol. SMTP is very chatty, so you can expect a few rounds of communication.

第一轮通信通常会告诉您是支持 SMTP 还是支持 ESMTP.第二轮(可选)通信是确定安全/加密/功能支持.最终,客户端"端将要求向特定地址/地址集发送消息.完成后,服务器将指示它已准备好获取电子邮件消息的正文.当邮件正文(及其可选附件)全部传输完毕后,MTA 会告诉您它已收到邮件.届时,MTA 将充当通过 DNS MX 记录发现的其他 MTA 的客户端,使您的电子邮件更接近目标 MTA,目标 MTA 会将其复制到某人的收件箱中.

The initial round of communication typically tells you whether SMTP is supported or ESMTP is supported. The second (optional) round of communication is to determine security / encryption / feature support. Eventually the "client" side will ask to send a message to a particular address / set of addresses. When done, the server will indicate that it's ready to get the body of the email message. When the body of the message (and it's optinal attachments) have all been transmitted, the MTA will tell you it received the message fine. At that point in time, the MTA will act as a client to other MTAs discovered via DNS MX records to get your email closer to it's destination MTA which will copy it into someone's inbox.

因此需要 MTA,因为客户端的邮件传递相当于将物理信件交给邮局.邮局负责邮局间路由(与 MTA 到 MTA 传输并行).然后,目的地邮局负责将信件投递到邮局信箱或家庭地址(与计算机收件箱相同).

So an MTA is needed because mail delivery on the client side is the equivalent to handing a physical letter to a post office. Post offices are responsible for inter-postoffice routing (which parallels to MTA-to-MTA transmission). The destination Post office is then responsible for delivery of the letter to the post office box or home address (which parallels one's computer inbox).

他们不会无缘无故地将其称为电子邮件邮件.

They don't call it e-mail for nothing.

--- 原帖如下---MTA 将接受邮件消息,查看它是否可以转发或投递它,如果可以转发或投递则做出响应,然后如果表明可以转发或投递它.

--- original post follows ---A MTA will accept a mail message, see if it can forward or deliver it, respond if it can be forwarded or delivered, and then forward or deliver it if it indicated it could.

消息如何接近它的最终目的地通常与 DNS 有一点关系.DNS 中的 MX(邮件交换)记录表示负责(或至少更接近负责服务器)特定电子邮件域名的服务器.如果不了解 DNS 的工作原理,就不可能完全了解邮件消息如何接近其目的地.

How the message gets closer to it's final destination usually has a bit to do with DNS. MX (mail exchange) records in DNS indicate servers which are responsible (or at least closer to the responsible server) for particular email domain names. It is not possible to fully understand how a mail message gets closer to it's destination without understanding how DNS works.

MTA 通常会查看递送地址,并且要么被配置为电子邮件地址的邮件域的端点",要么知道服务器 XYZ 距离电子邮件地址的邮件域更近一跳.如果它是一个端点,它会将消息从线路复制到某人的收件箱中.如果它正在中继,它会将消息转发"到下一个 MTA.

A MTA typically looks at the delivery address, and either is configured to be the "end point" of the email address's mail domain, or knows that server XYZ is one hop closer to the email address's mail domain. If it's an endpoint, it will copy the message from the wire into someone's inbox. If it's relaying it will "forward" the message to the next MTA.

这篇关于MTA 究竟是做什么的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-19 09:14