Article Title: Principles of the mail system. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
What is an email server? The mail server provides the basic structure of the mail system, including mail Transmission, mail distribution, and mail storage, to ensure that mail can be sent to any place on the Internet. Currently, advanced email servers include SMS emails, anti-virus and anti-spam modules, address book functions, user group functions, and POP3 receiving proxy. The mail server has two different application groups: ISP providers and enterprises. Email is one of Internet application services. The following describes the specific technical points of the email system.
MUA (client program, such as outlook)
MTA (mail transfer agent, mail transmission agent)
MDA (mail delivery agent, mail delivery agent)
MRA (mail retrieval agent, email retrieval proxy)
Real mail sending Process Simulation
If Alex uses a alex@gmail.com, the following steps are taken when Alex wants to mail to the john@yahoo.com:
· First, Alex wrote a letter from his PC and sent it to his gmail.com host.
· Gmail.com first stores the letter in the temporary storage area on its machine.
· Gmail.com checks the mail destination and finds the IP address of yahoo.com.
· Send emails to the host of yahoo.com over the Internet.
· After receiving a letter, the host of yahoo.com found that the letter was sent to the user on its own machine, so it was stored in the user's new inbox.
· When John is free, open the computer from home and take the initiative to go to yahoo.com to check whether there are new letters. When a new letter is found, download it to his computer.
From sending to receiving, each component on the network plays a different role.
· Mail User Agent (MUA): email User Agent, which is a program used by the User to write and receive emails. For example, we often use Outlook Exporess and Thunderbird. It provides users with an easy-to-use interface for sending and receiving mails, and transmits the mails to their own mail servers.
· Mail Delivery Agent (MDA): the Mail Delivery Agent, which is responsible for allocating emails to local users to users' mailboxes. In UNIX, MDA is usually a mail program.
· Mail Transfer Agent (MTA): the proxy for Mail forwarding. It is a server responsible for Mail forwarding. Sendmail and Postfix used in UNIX are MTA software. It serves to forward the mail to the destination based on the mail address after receiving the mail sent by MTU. In the destination, another MTA will receive the mail. Sometimes the mail will not be transferred from the user's computer to the host at the destination at a time, but will be transferred to the host at the destination through many MTA. This kind of MTA receives non-self-owned mails and transfers them to another MTA is called "Relay 」.
When sending a Mail, we use the SMTP (Simple Mail Transfer Protocol) communication Protocol. On a Mail server, we must first install the Mail server software, to receive emails from the SMTP protocol. The SMTP protocol is also used when messages are sent between MTA and MTA. When receiving a mail, the POP3 (Post Office Protocol) or IMAP (Internet Message Access Protocol) Protocol is used.
What is POP?
The full name of POP is Post Office Protocol, which is the Post Office Protocol for receiving emails. It uses TCP port 110. Currently, the third edition is commonly used, so POP3 is short. POP3 still adopts the Client/Server working mode. The Client is called a Client. Generally, we use computers as clients, while the Server (Server) is managed by network administrators. For example, Server is a collection of many small mailboxes, just like the mailbox structure of the building where we live, the client is like a person holding a key to unlock the mailbox to obtain the mail.
How POP works
Next let's take a look at the email receiving process of the email software. Generally, we set a POP server URL (such as pop) on the account attribute of the email software. 21cn. com), as well as the account and password of the mailbox. This is used in the receiving process. When we press the receiving key in the email software, the email software will first call the DNS protocol to resolve the IP address of the POP server. After the IP address is resolved, the mail program began to use the TCP protocol to connect to port 110 of the mail server. Because the POP server is busy, we have to wait a long time in this process. After the email program successfully connects to the POP server, it first uses the USER command to send the account number of the mailbox to the POP server, and then uses the PASS command to send the account of the mailbox to the server, after this authentication process is completed, the mail program uses the STAT command to request the server to return the mailbox statistics, such as the total number of mails and the size of mails, and then the LIST will LIST the number of mails on the server. Then the mail program will use the RETR command to receive the mail, and then use the DELE command to delete the mail in the mail server. When QUIT is used, the mail server deletes the mail with the deletion flag. In layman's terms, the Mail Program receives emails from the server, which is actually a conversation process. The POP protocol is a language used for email.
Command line pop Mail
Telnet pop. 21cn. com 110
+ OK Hermes POP service () is ready.
User mr22
+ OK
Pass svtest
+ OK mr22@21cn.com has 42 messages (3846240 octets)
Stats
+ OK 42 3846240
List
+ OK 42 3846240
1 637170
2 7047
3 1444
4 10938
5 3573
R etr 6
SMTP protocol Principle
SMTP-Simple Mail Transfer Protocol is a Protocol that defines Mail transmission. It is an application layer Protocol based on TCP services.
Command Line email
Ehlo xxxx
250-21cn.com, helo (DELAYED)
250-EXPN
250-HELP
250-8BITMIME
250-AUTH = LOGIN PLAIN
250-AUTH LOGIN PLAIN
250 XTMD
Auth login
What is a domain name? What makes a domain name?
A domain name is the name used to search for a website on the internet. It is an important identifier on the internet and is equivalent to a host's house number. Each host corresponds to an IP address, which consists of a series of numbers, such as 101.25.11.34. In order to facilitate memory, people use domain names instead of these numbers to search for hosts, such as mydomain.com. Each domain name corresponds to an IP address. people enter the domain name, and then the Domain Name Server (DNS) resolves it into an IP address to find the corresponding website. Domain names are required for each website or EMAIL. An English international domain name can contain up to 67 characters (including suffixes) and can contain English letters, Arabic numerals, and hyphens, each level can contain up to 22 letters. The length of a third-level domain name in China cannot exceed 20 characters.
What is DNS?
Domain Name System (DNS) is the Domain Name resolution server. its role on the Internet is to convert a domain name into an IP address that can be recognized by the network. for example, the input www.163.com will be automatically converted to 202.108.42.72
What is A record?
The A (Address) record is used to specify the IP Address record corresponding to the Host Name (or domain name. You can direct the website server under this domain name to your web server. You can also set a second-level domain name for your domain name.
What is an NS record?
The NS (Name Server) record is a Domain Name Server record, used to specify the DNS Server to which the domain Name is resolved.
What is an alias record (CNAME )?
It is also called a canonical name. This record allows you to map multiple names to the same computer. It is usually used on computers that provide both WWW and MAIL services. For example, there is A computer named "host.mydomain.com" (A record ). It provides WWW and MAIL services at the same time, in order to facilitate user access to the service. You can set two aliases (CNAME) for the computer: WWW and MAIL. The full names of these two aliases are www.mydomain.com and mail.mydomain.com ". In fact, they all point to "host.mydomain.com ".
What is wildcard domain name resolution?
Wildcard domain name resolution is defined as: the customer's domain name a.com, under which * .a.com all resolved to the same IP address. For example, if B .a.com is set, it will automatically resolve it to the same IP address as a.com.
What is an MX record?
The MX (Mail Exchanger) record is a Mail exchange Record pointing to an email server. It is used to locate the email server based on the recipient's address suffix when the email system sends an email. For example, when a user on the Internet wants to send a letter to a user@mydomain.com, the user's email system looks for the MX record for the domain name mydomain.com through DNS, if the MX record exists, the user's computer sends the email to the email server specified by the MX record.
Methods for checking the existence of MX records
A very useful tool for DNS query is nslookup, which can be used to query various data in DNS. You can directly run nslookup in Windows command line to enter an interactive mode, where you can query various types of DNS data.
DNS name resolution data can be of different types, including the SOA type data with the parameter set for this zone, and the type data with the IP address corresponding to the parameter set for this zone, there is MX data set for mail exchange. These different types of data can be queried through the nslookup interactive mode. During the Query Process, you can use the set type command to set the corresponding Query type. For example, C :\> nslookupDefault Server: [202.106.184.166] Address: 202.106.184.166
> Set type = mx
> Sina.com. cnDefault Server: [202.106.184.166] Address: 202.106.184.166
Non-authoritative answer:
Sina.com.cn MX preference = 10, mail exchanger = sinamx.sina.com.cn
Sina.com.cn nameserver = ns1.sina.com.cn
Sina.com.cn nameserver = ns3.sina.com.cnsinamx.sina.com.cn internet address = Hangzhou internet address = 202.106.182.230ns1.sina.com.cn internet address = Shanghai internet address = 202.108.44.55
If the MX record of a domain name does not exist, a message similar to the following is displayed: C: \> nslookup> set type = mx> amaxit.com. cnDefault Server: [202.106.184.166] Address: 202.106.184.166
* ** 202.106.184.166 can't find amaxit.com.cn: Non-existent domain
Command to confirm whether the email is received. If the SMTP receiver receives the message, an OK response is returned. If the SMTP receiver fails to receive the message, the receiver rejects the response (but does not stop the entire email operation. After receiving all emails, the recipient receives a special sequence. If the recipient successfully processes the emails, an OK response is returned. SMTP provides a mail Transmission Mechanism. If the recipient and the sender are connected to the same transmission service, the mail can be directly transmitted from the sender's host to the recipient's host; or, when the two are not in the same transmission service, they are transmitted through the relay SMTP server. To relay the SMTP server, it must have the destination host address and email name. The MAIL command parameter specifies the reply path, where the MAIL comes from, and the RCPT command parameter specifies the forwarding path, where the MAIL goes. The forward path is the source path, while the reply path is the return path (which is used to return an email when an error occurs ). When the same message is sent to different recipients, SMTP encounters the problem of sending copies of the same data to different recipients. The MAIL command and response have a strange syntax, the response also has a digital code. In the following example, we can see which actual commands and responses are used. Complete commands and responses are provided in section 4. Commands and responses are case-insensitive. That is to say, commands and responses can be uppercase or lowercase letters or a mixture of the two. However, this is not necessarily true for users' mail names, some hosts are case sensitive to user names. In this way, SMTP is being implemented.