Principles of the email system

Source: Internet
Author: User
Tags mail exchange mx record nameserver nslookup
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, the following steps are taken when Alex wants to mail to the

· First, Alex wrote a letter from his PC and sent it to his host.

· first stores the letter in the temporary storage area on its machine.

· checks the mail destination and finds the IP address of

· Send emails to the host of over the Internet.

· After receiving a letter, the host of 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 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 has 42 messages (3846240 octets)


+ OK 42 3846240


+ 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, helo (DELAYED)






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 In order to facilitate memory, people use domain names instead of these numbers to search for hosts, such as 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 will be automatically converted to

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 "" (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 and ". In fact, they all point to " ".

What is wildcard domain name resolution?

Wildcard domain name resolution is defined as: the customer's domain name, under which * all resolved to the same IP address. For example, if B is set, it will automatically resolve it to the same IP address as

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, the user's email system looks for the MX record for the domain name 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: [] Address:

> Set type = mx

> cnDefault Server: [] Address:

Non-authoritative answer: MX preference = 10, mail exchanger = nameserver = nameserver = internet address = Hangzhou internet address = internet address = Shanghai internet address =

If the MX record of a domain name does not exist, a message similar to the following is displayed: C: \> nslookup> set type = mx> cnDefault Server: [] Address:

* ** can't find 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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.