When you send an e-mail message (typically by means of an e-mail client), you are using the SMTP protocol. SMTP stands for Simple Mail Transfer Protocol and we could roughly define it as a set of rules and commands to send e-mail messages. The SMTP protocol is defined by the RFC 821. When you send an e-mail message, your SMTP server (the sender) establish a two-way connection to the receiver SMTP server. The receiver server maybe either the ultimate destination or an intermediate. Once the connection is established, the sending server send commands to the receiving server. As the receiving server receive one command it replies to the originating server sending a status code. In other words when you send an e-mail message by means of say Eudora, you connect to your SMTP server. Then you send some commands to your SMTP server. Your SMTP server establish a connection to the receiver server and then send it some commands, and receive the corresponding replies. Finally the connection is closed. Maybe you don't know that, but an e-mail client is not required to send e-mail messages. In fact you can connect to the SMTP server via telnet. You have to use the port number 25, because the SMTP server listen that port (each specified server listen a specified port, for example the HTTP server - the web server - listen the port 80, and the POP server listen the port 110). Let's see the main SMTP commands: - HELO yourhost (where yourhost is the name of the sender host. This command is used to identify the SMTP sender)
- MAIL youraddress (where youraddress is your e-mail address. This command starts a mail transaction in which the mail data is delivered to one or more mailboxes)
- RCPT recipientaddress (where recipientaddress is the recipient's address)
- DATA (this command is used to define the text of message. The text of message may contain any of the 128 ASCII character codes. The mail data is terminated by a line containing only a period, that is the character sequence "<CRLF>.<CRLF>" . In other words you have to press the enter key, then type a full stop and then press the enter key again)
- RSET (this command specifies that the current mail transaction is to be aborted)
- NOOP (It specifies no action other than that the receiver send an OK reply)
- QUIT (This command is used to close connection)
The commonest replies: 220 <domain> Service ready 221 <domain> Service closing transmission channel 250 Requested mail action okay, completed 354 Start mail input; end with <CRLF>.<CRLF> 421 <domain> Service not available, closing transmission channel 450 Requested mail action not taken: mailbox unavailable [E.g., mailbox busy] 500 Syntax error, command unrecognized [e.g., a command line too long] 501 Syntax error in parameters or arguments 502 Command not implemented 550 Requested action not taken: mailbox unavailable 551 User not local; please try <forward-path> 554 Transaction failed Example of session: S: telnet somewhere 25 R: 220 somewhere Simple Mail Transfer Service Ready S: HELO myhost R: 250 myhost S: color="#FF0000" size="2"> MAIL FROM size="2"><Smith@myhost> R: 250 OK S: color="#FF0000" size="2">RCPT TO size="2"><Jones@hishost> R: 250 OK S: color="#FF0000" size="2">DATA size="2"> R: 354 Start mail input; end with <CRLF>.<CRLF> S: Blah blah blah... S: ...etc. etc. etc. S: color="#FF0000" size="2"> . size="2"> R: 250 OK S: color="#FF0000" size="2">QUIT size="2"> R: 221 |