How email server works
I think many people send emails, as long as we have an email client, and then fill in the recipient address, sender address, and content to send an email. Of course, in our real life, the transmission of email may be very simple, but the implementation mechanism behind it is very complicated. In addition, due to the limitations of early technology, to implement a complete mail system, you may need a variety of servers. Therefore, it is very cumbersome and difficult to maintain the mail server created in this way. Later, for convenience, many functions of Jiujiang were integrated into one software so that many mail service functions could be implemented only by installing such software. This makes maintenance much easier.
Before talking about the mail server, we will first introduce several common component concepts of the server:
MUa: Mail User Agent, Mail User Agent. Its main function is to receive emails from the mail server, and to provide users with the function of browsing and writing emails. Generally speaking, it is an email client.
Common Mua software includes:
Outlook Express, Outlook
Foxmail
Thunderbird
Evolution
Mutt (text interface)
MDA: mail delivery agent, mail delivery agent. Its main function is to analyze the header and content of the mail received by the MTA and determine the destination of the mail. If the message received by the MTA is sent to the user, the message is forwarded to the user's mailbox. If not, the message is forwarded.
Common MDA software:
Procmail
Maildrop
MTA: Mail Transfer Agent, mail Transmission proxy. It is mainly used to receive mails. The protocol used to receive mails is SMTP (Simple Mail Transfer Protocol, Simple Mail transmission protocol ), the listening port number is 25. Of course, we generally refer to the mail server as the MTA. In fact, the MTA only refers to the SMTP protocol.
Common software that provides MTA functions include:
Relatively old sendmail
Postfix: the software is modular and secure. It is compatible with Sendmail and is more efficient than Sendmail.
Qmail
Exchange (Windows, asynchronous message collaboration platform)
Of course, the MTA software we use later is Postfix.
MRA: Mail retrieval agent, an email retrieval proxy. You can use the (POP3 or IMAP4) Protocol to accept your own mail. Of course, POP3 and IMAP4 receive messages differently. Here I will introduce the two methods:
POP3 receiving method:
1. Mua (mail client software) connects to port 110 of MRA through POP3 (Post Office procotol version 3, postal service protocol), and Mua needs to provide the account and password for correct authorization. This authorization is performed by the POP3 protocol in the database to retrieve the correct account and password for authorization. Therefore, MRA also needs to work with the database, which will be discussed later.
2. After confirming that the account and password are correct, the user's email is sent to the user's email address and sent to the Mua software.
3. After all emails are sent, the data in the user's mailbox (Mailbox) will be cleared.
Method of receiving IMAP4:
First, you also need to obtain the authorization through the account and password to get the mail in the user's mailbox (Mailbox), but he not only returns the obtained mail to MUa, but also saves the mail in ~ /User account/directory. In this way, the user can permanently view the email.
Therefore, you only need to use SMTP and POP3 protocols to create a complete mail server.
Common MRA:
Cyrus-imap
Dovecot
Next we will introduce how a complete email server works:
1. First, the user writes an email using the Mua software and transmits it to the local SMTP server using the SMTP protocol. (remember, this is the local SMTP server, not the destination SMTP server, here we will refer to the SMTP server smtpd for short)
2. After receiving the email from MTA, if the target side of the email is local, then the MDA will store the email in the user's mailbox (Mailbox); if not, you need to call the SMTP client (SMTP for short), and the MDA will forward it to the next MTA. In this case, if no action is taken, then all the people only need to connect to the local, all emails can be sent, and the MDA will forward it to the next MTA. We call this transfer method open relay ). Of course, this method is insecure. If someone sends unhealthy or illegal emails, the following negative effects may occur:
(1) Use MTA network bandwidth
(2) because the Internet is defined as a blacklist, many normal emails cannot be sent.
(3) the IP address may be blocked by the upper-level carrier, and other adverse factors
Therefore, for the sake of security, the user must provide the account and password for authorization before sending an email using MUa, so that the MTA can only provide relay for these authorized accounts, you can forward emails normally. Of course, SASL (simple authentication secure layer, simple authentication security layer) is used to verify whether the account has relay services. Of course, it is also verified by checking whether the account and password are correct in the database. Therefore, it also needs to be used together with the database.
3. The local SMTP server calls the SMTP client (SMTP) to establish a TCP connection with the next SMTP server. After receiving the mail, the target SMTP server analyzes the header and content of the mail, determines the destination of the letter. If the target is local, it will be forwarded to the user's mailbox; if not, continue to forward to the next MTA (the subsequent process is the same as this ).
4. The client receives an email and, of course, requires authorization through the account and password, and establishes a connection with MRA. POP3 is used here. POP3 checks whether the account and password are correct in the database. If there is no problem with the account and password, it obtains an email from the user's mailbox, returns it to the POP3 server, and returns it to the client on the POP3 server.
This article from the "Linux learning path" blog, please be sure to keep this source http://xslwahaha.blog.51cto.com/4738972/1560462
How email server works