E-mail protocol detailed

Transmission and reception of messages --STMP, POP, IMAP, MIME

E-mail protocol is a "push" based protocols, including SMTP; mail receiving protocol is based on the "pull" of the agreement, including POP and IMAP protocol agreement, before the formal introduction of these agreements, we give the architecture of the mail:

 

 

 As can be seen from the figure the entire mail process is as follows:

       (1) the sender to call the user agent edit the message to be sent.

       (2) "Send Mail" button on the sender click on the screen, all of the work sending mail to the user agent to complete. User agent will be sent via SMTP protocol messages to the sender's mail server (in this process, the user agent to act as SMTP client, and the sender's mail server acts as an SMTP server).

       (3) The sender's mail server receives mail sent to the user agent, put the mail received in the mail temporarily stored in the buffer queue, waiting time is ripe and then sent to the recipient's mail server (the length of waiting time depending on the number and the mail server processing power to be transmitted in queue letters).

       (4) If the time is ripe now, the sender's mail server sends the mail to the mail cache of the recipient's mail server. Before sending a message, SMTP customers with the recipient's mail server of the sender's mail server SMTP server requires the prior establishment of a TCP connection, and then later sent message in the queue. It is worth noting that the mail will not be on the Internet in the middle of a mail server floor.

       SMTP server processes (5) receiving mail server after receiving the message, the recipient of the message into the user's mailbox, waiting for the recipient to read.

       (6) when the intended recipient in receiving, run the PC user agent, sent their messages using POP3 (or IMAP) protocol read. Note that, in this process, it is the recipient POP3 clients, and incoming mail server is a POP3 client, the direction the arrow is pointing users to receive e-mail from the server, because this is a "pull" operation.

 

       Here we introduce the various components of the overall process above.

        1. User Agent

        User Agent UA (User Agent) is a software package (program), its function is: write, read, reply and forward messages, can handle the mailbox (such as creating inbox and outbox). There are two types of user agents: command-driven and GUI. Command-driven early email belongs, send and receive messages from the command, and the GUI is a graphical interactive, allowing the user to use the keyboard and mouse to interact with the software.

 

       2. SMTP protocol

        Well-known port number of the SMTP protocol the server 25, similar to the previously summed up where the FTP protocol and the telnet protocol is that the client and server are SMTP protocol to interact with the form of commands and responses, i.e. SMTP command to the client SMTP server to send an operation request, and the server 3 through the digital response to respond to the request. SMTP provides 14 and 21 command response messages, each command has 4 letters, and each line of information is generally only reply with a 3-digit code starts, appended to a very simple annotated.

    

  Mail delivery mainly consists of three phases: establishing a connection, mail delivery and terminate the connection.

 

       Establish a connection phase:

       1. When a client SMTP messages at regular intervals to scan a cache, such as found in the message, to establish a TCP connection to the SMTP server SMTP well-known port 25 with the recipient mail server.

       2. The recipient SMTP server sends a "220 Service ready" to tell the client that it is ready to receive mail. If the server is not ready, it sends the code 421 (server is not available).

       3. The client sends HELO message, and uses its own domain name address signs. The purpose is: to notify the customer's domain name server, it is worth noting that the TCP connection establishment phase, the sender and recipient are telling each other by their IP addresses. (HELO message is the initial user names and passwords are not encrypted. Now instead EHLO, user names and passwords are base64-encoded sending)

       4. The server response code 250 (request command completion), or some other code according to the situation.

 

      Messaging stages:

       After establishing a connection between the client and the SMTP server, the sender can exchange a single message with one or more recipients. If more than one recipient, the following steps 3 and 4 will be repeated.

        1. The client sends the message introduced MAIL FROM sender of the message. It includes e-mail address of the sender (email and domain names, such as house @ qq). This step is necessary: ​​because you can return to the server when the e-mail address or return error messages.

        2. The server response code 250 (request command completion), or other appropriate code.

        3. The client sends RCPT (recipient) message, including the recipient's e-mail address, the role of RCPT command is: first, to find out if the receiver system is ready to ready to receive mail, before sending mail to do so, as the to avoid wasting communication resources, and will not send a long message later I learned that due to wrong address.

        4. The server response code 250, or other appropriate code.

        5. The client sends packets to the DATA packet transmitted is initialized, DATA command pledged to start transferring the contents of the message.

        6. The server response code "354 Start mail input: end with <CRLF> <CRLF>." Or other appropriate message (e.g., server 421 is unavailable, the command does not recognize 500).

        7. The client sends the contents of the packet with a continuous line. Input line at the end of each line <CRLF>. <CRLF>, i.e., carriage return. Carriage return line, the end of message content.

        8. The server response code (250 completion request command) or other appropriate code.

 

        It is worth noting: While trying to make a TCP connection using the SMTP transmission and reliable e-mail, but it does not guarantee that the message is not lost. That is, using SMTP to send mail only say that can reliably deliver the recipient's mail server, in case of future do not know. The recipient's mail server might fail, the server receives a total loss (before reading the letter recipient).

 

        Terminate the connection

        After the success of messaging, the customer terminates the connection. Comprising the steps of:

        1. The client sends QUIT command.

        2. The server response 221 (server is down), or other code.

        After connecting the termination phase, TCP connection must be closed.

        3.POP agreement

        POP protocol, Post office Protocal. The first and second phases of the mail delivery using SMTP, while the third stage is used to read e-mail protocol. SMTP is a push protocol, and the third stage pull protocol is used, including POP and IMAP protocols, mainly POP using POP3, IMAP protocol is mainly used and IMAP4.

        POP3 work using the C / S. The UA in the user's PC to receive mail in POP3 client program must be running, and then run the POP server program in the recipient ISP mail server connection. POP server only after the user enters authentication information (username + password) before allowing the other party to the mailbox for reading.

        POP3 works in two ways: to delete mode and save mode. Delete way to put the mail in the mailbox deleted after every read mail, saving is still the way to save the mail in the mailbox after reading the message, which is by the way POP3 works prior to (ie delete) shortcomings make up for function expansion.

 

         4. IMAP protocol

        IMAP protocol, Internet Mail Access Protocal (Internet Mail Access Protocol). IMAP protocol is more complex than POP3 protocol, the way work is in accordance with C / S, and now the newer version is IMAP4.

        When using IMAP, the user's PC to run an IMAP client program, and then establish a TCP connection to the IMAP server program on the recipient's mail server. POP3 does not allow users organize on their own mail server mail user on the server can not be different folder, POP3 does not allow users to read part of the message before downloading e-mail, IMAP and POP3 overcomes these shortcomings, saying white the POP3 protocol is reluctant to allow users to directly manipulate the server, and IMAP clients just these shortcomings.

        IMAP4 provides the following functions (these functions are not POP3):

        1. Users can check mail before downloading the mail header.

        2. user before downloading message content-specific search string of e-mail can be used.

        3. Users can download e-mail part.

        4. The user can create on the mail server, deleting a mailbox, the mailbox or renamed. (IMAP is bi-directional, you can synchronize local modifications to the server; POP only local synchronization service end)

        5. In order to store e-mail, users can create a hierarchy of folders in the mailbox.

        Note: Do not send the mail protocol SMTP protocol mail protocols POP or IMAP protocol to read confuse. UA sends the sender's mail server to send mail, and the sender's mail server to the recipient's mail server to send mail and are based on SMTP protocol, and the recipient's UA receives from the mail server receives the file uses the POP protocol or IMAP protocols.

 

       5. MIME

        MIME protocol (Multipurpose Internet Mail Extensions), Common Internet Mail Extensions, as a supplementary protocol SMTP, incorporated in order to overcome the lack of SMTP as follows:

        1.SMTP only be sent using NVT (network virtual terminal) 7 messages in ASCII format, it can not use language NVT 7-bit ASCII are not supported (such as Chinese, Japanese, German, etc.).

        2.SMTP not transmit binary objects or other executable files (such as image files).

        3.SMTP does not support audio or video files.

        4.SMTP mail transmission length is limited.

        To overcome these shortcomings, it introduced the MIME protocol, MIME protocol is an extension of the supplementary protocol agreement, "expansion" refers only an extension of the agreement, rather than replace. It allows non-ASCII code data can be transmitted by e-mail. MIME sender converts non-ASCII code data is ASCII data NVT, after completion of work and then to the SMTP, the recipient and then restore the original data NVT ASCII data. MIME architecture is as follows:

 

 

MIME defines five headers, plus used in the original e-mail section to define the parameters of the conversion, the first part of the other five are: MIME-Version (MIME version), Constent-Type (content type), Content-Transfer-Encoding (content - transfer - encoded), content-Id (content - identification) and content-description (description).

 

        MIME version: Defines the MIME version used.

       Content - Type: data type and subtype definitions used in the packet body, by <data type / subtype> FIG.

        Content - Transfer - Encoding: it defines the body of the message when delivery is coded.

        Content - Tags: multi-packet environment that uniquely identifies the message.

        Description: defines the body is an image, audio or video.

 

        6. WWW-based mail

        Architecture based mail system different from the conventional WWW email delivery systems, based on the entire mail system WWW process described below:

        1. transmitted from the browser to the sender the sender mail server via HTTP protocol (and generally is by the SMTP protocol).

        2. the server from the sender to the recipient mail server via SMTP protocol (same general).

        3. from the receiver to a receiver via HTTP protocol (and general protocol is POP3 or IMAP protocols).

        Specifically as shown below:

 

 

In:

https://blog.csdn.net/suhuaiqiang_janlay/article/details/78765613

Guess you like

Origin www.cnblogs.com/gd-luojialin/p/10963030.html