What is the Simple Mail Transfer Protocol?
A simple mail transfer protocol(SMTP) is used to transfer the mails. The actual mail transfer is done through MTA, i.e. Message Transfer Agents. The system must have the client message transfer agents and server message transfer agents to transfer mail from one system to another.
The client MTA is responsible for initiating the email-sending process. It communicates with the SMTP server to transmit the email from the sender’s system to the sender’s mail server. On the other hand, the server MTA operates on the recipient’s side. It receives emails from client MTAs and delivers them to the intended recipients. SMTP defines the rules and procedures for communicating between these client and server MTAs. It includes specifying the format for commands and responses exchanged between them.
How does the Simple Mail Transfer Protocol Work?
To transfer messages between Messages Transfer Agents client and message transfer agents sever, simple mail transfer protocol uses commands and responses.
First, the MTA client sends commands to the MTA server; in response, the MTA server sends responses to the MTA client.
SMTP Commands
Let us see those commands and responses one by one. Commands are sent from the client to the server. The syntax of the command is shown below.
Keyword: argument(s)
The simple mail transfer protocol defines different commands shows as below.
1) HELO
The client uses this command to identify himself. The argument is the sender’s hostname. The format is shown below:
HELO: challenger.atc.educba
2) MAIL FROM
The client uses this command to identify the sender of the message. The argument is the sender’s e-mail address. The format is shown below:
MAIL FROM: [email protected]
3) RCPT TO
The client uses this command to identify the intended recipient of the message. The argument is the receiver’s e-mail address. The format is shown below:
RCPT TO: [email protected]
4) DATA
The client uses this command to send the message. All lines that follow the DATA command consider as a mail message. The format is shown below:
DATA: This is the message which is being designed to send to the receiver.
5) QUIT
The client uses this command to terminate the message. The format is shown below:
QUIT
6) REST
The client uses his command to cancel the current mail transaction. The connection will reset, and the stored information about the sender and the receiver will be deleted. The format is shown below:
REST
7) VRFY
The client uses this command to verify the receiver’s e-mail address. The format is shown below:
VRFY: [email protected]
8) NOOP
The client uses this command to check the status of the recipient. The format is shown below:
NOOP
9) TURN
Both the sender and receiver use this command to switch their positions, i.e. the sender becomes a receiver, and the receiver becomes the sender. In today’s world, a simple mail transfer protocol does not support this feature. The format is shown below:
TURN
10) EXPN
This command asks the receiver’s host to expand the mailing list, which is sent as arguments and return the receiver’s mailbox addresses that comprise the list. The format is shown below:
EXPN: a b c d
11) HELP
This command asks the receiver to send the information about the command, which is sent as an argument.
HELP: mail
12) SEND FROM
This command specifies that the mail is to be delivered to the recipient’s terminal and no to the mailbox. If the recipient is offline, then the mail is bounced.
SEND FROM: [email protected]
13) SMOL FROM
This command specifies that the mail is to be delivered to the terminal or the recipient’s mailbox. If the recipient is online, then the mail is sent directly to the terminal. If the recipient is offline, the mail is sent to the mailbox.
SMOL FROM: [email protected]
14) SMAL FROM
This command specifies that the mail is to be delivered to the terminal and the recipient’s mailbox. If the recipient is offline, the mail is sent to the terminal and the mailbox. If a recipient is online, the mail is directly sent to the mailbox.
SMAL FROM: [email protected]
15) VERB
Enables or disables verbose mode.
16) TICK
Inserts an identifier into the batch SMTP response data set.
Responses
Responses are sent from the server to the client. It is a 3 digits code that may follow some information in text format. Those Simple mail transfer protocol Response Codes are given as follows:
- 211: Status of the system
- 214: Help message
- 220: Service ready
- 221: Service closing transmission channel
- 250: Requested command complete
- 251: Message will be forwarded
- 354: Start mail input
- 421: Service not available
- 403: User is not authorized to send from this email address. i.e. User needs to update the current email address.
- 450: Mailbox not available
- 451: Command aborted due to local error
- 452: Command aborted due to insufficient storage
- 500: Syntax error due to unrecognized command
- 501: Syntax error due to parameter or arguments
- 502: Command not implemented.
- 503: Bad sequence of commands
- 504: Command temporarily not implemented
- 550: Command not executed
- 551: User not local
- 552: Requested action aborted
- 553: Requested action not taken
- 554: Transaction failed
Conclusion
This article has seen what Simple Mail Transfer Protocol is, how it works, and commands to establish, maintain, and terminate the Simple Mail Transfer Protocol configuration.
Recommended Articles
This is a guide to the Simple Mail Transfer Protocol. Here we have discussed the basic concept; how does it work? Along with Different commands in SMTP. You may also have a look at the following articles to learn more –