邮件发送的基本过程
【文章来自:古风】

这里总结下邮件发送的基本过程

邮件用户代理(Mail User Agent,MUA):即通常所说的邮件客户端软件,它帮助用户读写和管理邮件。

邮件传输代理(Mail Transport Agent,MTA):在邮件传递过程中经过的一系列中转服务器的统称,它们将邮件发给最终收件服务器或其他的中转服务器。

邮件投递代理(Mail Deliver Agent,MDA):即收件服务器,它负责接收并保存发给用户的邮件。

1.一台邮件服务器,可能作为邮件的出发点,也可以作为邮件的目的地,甚至可以作为邮件的中间转运站。

由图可以看到,1可能是你用来发送邮件的软件,程序(MUA),2则为信件到达的第一台邮件服务器,可以认为2这台邮件是邮件服务器链里的出发地。自然3就是中转节点,4为目的节点。

中间服务器可有可无

2.邮件在网络上的流动过程

举例:使用83378122@163.com给dxt02880466@qq.com发送邮件

(1)、163发送程序检查目标邮箱的域名qq.com

(2)、如果目的邮箱为本地域名,则调用本地MDA发送邮件(localmessage)。可惜不是。进入转发流程RELAY

(3)、通过dns查询qq.com的MX记录,并按照优先顺序选择优先级最高的mx服务器,这里是mx3.qq.com

(4)、通过DNS查询mx3.qq.com的A记录

(5)、尝试连接MX3.QQ.COM

(6)、如果连接失败,则选择第二优先级MX mx2.qq.com,重试步骤4,仍然不行尝试mx3

(7)、如果所有MX都连接失败,则返回不发连接异常(有的系统会有重试或者软弹回)

(8)、如果连接成功,则使用SMTP发送邮件给这个邮件网关。

(9)、当然如果接受域没有mx记录,则尝试查询其A记录并发送邮件到A记录。如果MX记录和A记录都连不上,则视为不可发送返回给发件人。

(10)、最后qq邮箱在接收到递送过来的邮件后会执行第二步。

3.《lINUX E-MAIL》中关于DNS记录在email中应用的说明

How does an SMTP server discover to which host a message for a certain domain should be delivered? The recipient domain is, not surprisingly, used as the key in one or more DNS lookups. The first lookup that is made is for the mail-specific MX record—the mail exchanger record type. The MX entry allows the DNS operator to specify the hostname or hostnames of servers that can receive mail for a certain domain. For example, MX records can be used to specify that messages to someone at example.com should be sent to mail.example.com. If the recipient domain does not have an MX record, an attempt is made to find an A record for the recipient domain. If the A record lookup succeeds, the mail will be delivered to the host. If both the MX and A lookups do not return any results, the message is deemed undeliverable and is returned to the sender.

4.图解一下传输过程。