Simple Mail Transfer Protocol (SMTP)
1.Introduction
The goal of Simple Mail Transfer Protocol (SMTP) is to deliver mail reliably and efficiently. It is independent of the transfer subsystem and requires only one channel that can ensure the order of transmitted data units. Appendix A, B, C, and D describe the use of SMTP in different transfer services. The terms used in this document are also defined in the glossary.
An important feature of SMTP is its ability to transmit mails during transmission. The transfer service provides an inter-process communication environment (ipce), which can include a network, several networks or subnets of one network. It is important to understand that the transfer system (or ipce) is not one-to-one. The process may directly communicate with other processes through known ipce. An email is an application or inter-process communication. Emails can be sent across the network through processes connected to different ipce. More specifically, emails can be transmitted over hosts on different networks.
2.SMTP Model
SMTP is designed based on the following communication model: a two-way transmission channel is established between sending SMTP and receiving SMTP for users' mail requests. The receiving SMTP can be the final receiver or intermediate transmitter. The SMTP command is sent by the sending SMTP and received by the receiving SMTP, while the response is sent by the opposite side.
Once the transfer channel is established, the SMTP sender sends the MAIL command to specify the mail sender. If the SMTP recipient can receive the email, an OK response is returned. The SMTP sender then sends the RCPT command to check 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, the SMTP implementation retains the user's mailbox name as the initial form, and the host name is not case sensitive.
Commands and responses are composed of the ASCII alphabet. When the shipper service provides an eight-byte Transfer Channel, each 7-bit character is correctly transmitted, and the highest bit is filled with 0. When a common command or response format is specified, the parameter is expressed by a string similar to a language, such" "Or" ", Angle brackets indicate that this is a language-like variable.
3.SMTP process
This section provides some SMTP processes. The first describes the basic sending process (defined as the sending operation ). Next, describe the forward mail, confirm the email name and the extended email list, send it to the terminal, and enable and disable the exchange. At the end of this section is a description of the interrupt and email domain. The example in this section is only a part of the command and response sequence. For the complete example, see Appendix F.
3.1. Mail
There are three steps in the SMTP sending operation. The operation is identified by the MAIL command. After a series of or more RCPT commands keep up with it, the receiver information is provided, the Data command is used to list the sent mail content, and the mail content indicator is used to confirm the operation.
The first step in the process is the MAIL command, including the source mailbox.
Mail From:
This command tells the recipient that the new sending operation has started. Please reset all status tables and buffers. It provides a reverse path to return error information. If the request is received, the receiver returns a 250 OK response. It includes not only the mailbox, but also the reverse routing of the host and the source mailbox. The first host is the host that sends the command.
The second step in the process is to send the RCPT command.
RCPT To:
This command identifies the receiver in the forward path. If the command is received, the receiver returns a 250 OK response and stores the forward path. If the receiver is unknown, the receiver returns a 550 failure response. This process may be repeated several times.
It includes not only emails, but also route tables of hosts and destination mailboxes. The first host is the host that receives commands.
The third step in the process is to send the data command.
Data
If the command is received, the receiver returns a 354 intermediate response, and determines that the following lines are the mail content. After receiving and storing the ending letter, the receiver sends a 250 OK response. Because the email is sent through the transmission channel, you must specify the end of the message so that the reply dialog can start again. SMTP sends only one full stop message in the last line to indicate the end of the mail content. In the receiver, this symbol is filtered out in a transparent process to the user, so that normal data is not affected.
Note: The Mail content includes the following prompts: date, subject, to, CC, from.
The email content indicator confirms the email operation and informs the recipient that the data can be stored and sent again. If this command is received, the receiver returns a 250 OK response. The Data command fails only when the email operation is incomplete or the source is invalid.
The above process is a sending operation. These commands can only be used in the preceding sequence. The following example shows how to use these commands in a sending operation.
-------------------------------------------------------------
SMTP process example: in this example, Smith of the Alpha. Arpa host sends an email to Jones, green, and Brown of the Beta. Arpa host. Assume that the Alpha of the host is directly connected to the beta of the host.
S: mail from:
R: 250 OK
S: rcpt:
R: 250 OK
S: rcpt:
R: 550 no such user here
S: rcpt:
R: 250 OK
S: Data
R: 354 start mail input; end .
S: blah...
S:... and so on
S: .
R: 250 OK
This email was received by the first two people, and the third person had no email on this host.
-------------------------------------------------------------
3.2. The forwarding is as follows: The target address is incorrect, but the recipient knows the correct target address. In these examples, one of the following responses should allow the sender and obtain the correct address.
251: the user is not local. .
This response means that the receiver SMTP knows that the user's mailbox is on another host, and that the correct redirection path will be used in the future. Note that the host or user, or both, are different. The receiver is responsible for transmitting messages.
551: the user is not local. Please try
This response means that the receiving SMTP knows that the user's mailbox is on another host, and the correct forwarding path is used. Note that the host or user, or both, are different. The recipient rejects the receipt of this user's mail. The sender must resend the email Based on the provided information or return an error message to the original sender.
The following example shows the applications with these responses.
Forwarding example
S: rcpt:
R: 251 user not local; will forward
Or
S: rcpt:
R: 551 user not local; please try
-------------------------------------------------------------
3.3. Validation and Expansion
SMTP provides additional user name confirmation and extended Mail List functions. These functions are completed by the vref and EXPN commands, both of which take strings as parameters. For a vref command, the string parameter refers to the user name. The response to this command should include the user name and the user's mailbox. For the EXPN command, the string parameter refers to the Mail list. There are more than one response to this command, including the names of all users in the list and their mailboxes.
"User Name" is a redundant project, which is intentionally added. If the host uses the vref and EXPN commands, the user name must be provided in the local mailbox for confirmation by the host. This parameter is also allowed if another string is selected as the user name on the host.
In some hosts, the mailbox list and the proxy of a mailbox are a little unclear, because the general data structure may include two types of portals. If you want to confirm the email list, a confirmation response should be given. After receiving the message, the host sends the email to all the addresses in the list. If no response is received, an error is reported. For example, "550 that is a mail list, not a user name ". If a request is used to expand a user name, a definite response may be formed by returning a list containing a name. If no definite response is received, an error is reported. (For example, "550 that is a user name, not a mailing list ").
In the case of multiple responses (usually for EXPN), each response specifies a mailbox. In case of fuzzy requests, for example, "VRFY Smith", the two Smith responses must be "553 user ambiguous ".
The user name is confirmed as follows: Example 3:
-------------------------------------------------------------
Confirm User Name
S: VRFY Smith R: 250 Fred Smith
Or
S: VRFY Smith
R: 251 user not local; will forward
Or
S: VRFY Jones
R: 550 string does not match anything.
Or
S: VRFY Jones
R: 551 user not local; please try
Or
S: VRFY gourzenkyinplatz
R: 553 user ambiguous.
-------------------------------------------------------------
The mailbox list requires multiple responses as follows:
-------------------------------------------------------------
Example of extended email list
S: EXPN example-people
R: 250-jon Postel
R: 250-fred fonebone
R: 250-sam Q. Smith
R: 250-quincy Smith
R: 250-
R: 250
Or
S: EXPN executive-memory room-list
R: 550 access denied to you.
-------------------------------------------------------------
The string command parameters of the Verf and EXPN commands cannot be limited because of different implementations. In some systems, the EXPN command parameter may be a file name containing the mail list, but there are many different file structures on the Internet.
VRFY and EXPN commands are not included in the minimum implementation. When they are implemented, they are not required to be implemented between the transmissions.
3.4. send and receive the mail (sending)
SMTP is mainly used to send emails to users' mailboxes. Similar functions provided by some hosts are to send emails to the user's terminal (if the user is on the terminal ). Sending an email to a user's mailbox is called sending mail (mailing), while sending an email to a user's terminal is called receiving mail (sending ). The implementation of the two is very similar on some hosts, so they are put into SMTP at the same time. However, obtaining mail commands is not available in the minimum implementation of SMTP. Users should be able to write information to terminals. Most hosts allow users to accept or reject similar information.
The following three commands are defined to support receiving letters. They are used for mail commands instead of mail commands to indicate the special significance of receiving SMTP operations:
Send From:
The send command requires that the mail content be directly transmitted to the user terminal. If the user does not open the terminal (or does not receive the terminal information), the 450 response will return an RCPT command. If the message is successfully sent, this operation is successful.
SOML From:
The send or mail Command requires that the mail content be directly sent to the user's terminal (if the user is on the terminal ). If the user is not on the terminal, the email content is directly sent to the mailbox. If the email is sent to the user terminal or user mailbox, the sending operation is successful.
SAML From:
The send and mail commands require that the mail content be directly sent to the user terminal (if the user is on the terminal ). In any case, the mail will enter the mailbox. If the mail enters the mailbox, the sending operation is successful.
The responses for mail commands are the same as those for these commands.
3.5. Open and Close
When a transfer channel is opened, some information needs to be exchanged to determine the identities of both parties. The following command is used to enable and disable the service:
Helo
Quit
In the hello command, the host sends the command by itself. This command can be interpreted as "Hello, I am xx ".
-------------------------------------------------------------
Example of opening a connection
R: 220 BBN-UNIX.ARPA Simple Mail Transfer Service ready
S: HELO USC-ISIF.ARPA
R: 250 BBN-UNIX.ARPA
-------------------------------------------------------------
-------------------------------------------------------------
Example of disabling a join
S: Quit
R: 221 BBN-UNIX.ARPA Service closing transmission channel
-------------------------------------------------------------
3.6. Forwarding
The forwarding path may be in the following format: "@ one, @ two: Joe @ three". Here, one, two, and three are hosts. This format emphasizes the differences between addresses and paths. The email address is an absolute address and the path is about how to arrive. These two concepts should not be confused.
In concept, the element of the forwarding path is moved to the reply path as the information from one SMTP server to another SMTP server. The reply path is a reverse Data Source Path, for example, from the current information location to the initiator location. When an SMTP server deletes its own tag from the forwarding path and inserts it into the reply path, it must use a name that can be understood by its sending environment, in case that its name is understood as a different name in different environments.
If the first element of the forwarding path received by SMTP is not the SMTP tag, this element is used to determine the next SMTP server to be sent instead of being deleted from the forwarding path. In any case, SMTP adds its own tag to the reverse path.
When you use the source path, you can receive the forwarded mail from SMTP and send it to another receiving SMTP server. The receiving server can accept or reject emails forwarded to local users. Receiving SMTP changes the command parameters by moving its own flag from the forwarding path to the beginning of the reply path. At this time, the receiving SMTP is changed to sending SMTP, And the SMTP channel is established to the next forwarding path, and then it sends emails to this SMTP.
The first host in the reply path should be the host that sends the SMTP command, and the first host in the forwarding path should be the host that receives the SMTP command.
Note: The forwarding and reply paths appear in SMTP commands and responses, but do not necessarily appear in the information. That is to say, there is no such path, especially this format appears in the "to:", "From:" and "cc:" fields of the Information header.
If the SMTP Server accepts the forwarding task, but later it finds that the mail cannot be sent due to incorrect forwarding path or other principles, it must establish an "undeliverable mail" signal, send this signal to the sender of the message.
This signal must be sent from the SMTP service of this host. Of course, this server should not report any error messages. One way to prevent this error reporting loop is to leave it blank on the reply path of the MAIL command of the signal. When this information is sent, the reply path can also be left blank. The reply path after a MAIL command is empty as follows:
Mail from:
The following example shows the mail information that cannot be sent. This message is a response to an error that occurs when hostx needs to pass hostz to Hosty. The example we see is between hostx and Hosty.
-------------------------------------------------------------
Example of mail Information Not Allowed
S: mail from:
R: 250 OK
S: rcpt:
Previous Article: POP3 protocol specification (Chinese Version)
Next article: Telnet protocol specification (Chinese Version)