From the previous communication model, you can see that the SMTP protocol's session between sending SMTP and receiving SMTP is done by sending SMTP commands and receiving an answer to SMTP feedback. After the communication link is established, Send SMTP send mail command message sender, if receive SMTP at this time can receive mail then make OK answer, and then send SMTP continue to Issue RCPT command to confirm whether the message received, if received on the answer to OK, otherwise issued a refusal to receive answers, However, this does not affect the entire message operation. The two sides have been repeated so many times until the message is processed. The SMTP protocol contains a total of 10 SMTP commands, which are listed below:
SMTP Command Command description
Hello Identifies the sender to a Hello command to receive SMTP
Mailfrom: is the sender's address. This command tells the receiver the beginning of a new mail delivery and initializes all States and buffers. This command begins a message transfer process that ultimately completes the delivery of the message data to one or more mailboxes.
Rcptto: Identifies the addresses of individual message recipients
DATA
Receiving SMTP will treat the behavior that follows as mail data to . to identify the end of the data.
REST exit/Reset the current message transfer
NOOP requires the receive SMTP to do only the OK answer. (For testing)
QUIT requires that receive SMTP return an OK answer and turn off the transmission.
VRFY verifies that the specified mailbox exists, and because of security factors, the server suppresses this command more than once.
EXPN verifies that a given mailbox list exists, and that expanding the list of mailboxes is often prohibited.
Help What command does the query server support?
Note: The returns, wraps, and ASCII codes are 13, 10 (decimal), respectively.
Each command of the SMTP protocol returns an answer code, each of which has a specific meaning, such as the first digit of 2, the command succeeds, the 5 table fails, and the 3 table is not completed. Some of the more complex mail programs use this feature, first check the answer code first number, and based on its value to determine the next move. The following list of SMTP answer codes is as follows:
Answer Code Description
501 Parameter Format error
502 Command not implemented
503 Wrong sequence of commands
504 Command parameter not implemented
211 System State or system help response
214 Help information
Service Ready
221 Service shutdown
421 Service not ready, turn off transport channel
250 required mail operation completed
251 The user is not local and will forward to
450 The requested mail operation was not completed and the mailbox is not available
550 The requested mail operation was not completed and the mailbox is not available
451 abort the required operation; error occurred during processing
551 user is not local, try
452 system storage insufficient, required operation not performed
552 Excess storage allocation, required operation not performed
553 The mailbox name is not available and the requested operation is not performed
354 start the message input to "." End
554 operation failed