The Simple Mail Transfer Protocol (SMTP) is used to transfer messages across a network. It
is defined in RFC 821. Under TCP/IP the SMTP protocol is implemented as an application layer protocol that uses Transmission Control Protocol (TCP) to establish a reliable connection between two systems. In a single session multiple mail and information messages can be transmitted in either direction across the link. One important feature of SMTP is its ability to relay mail across multiple environments. Mail may cross multiple networks using various media in its path from source to destination.
TCP uses a pair of ports numbers, one for source and one for destination, to identify each communications link. By default an SMTP client application will contact the remote server using TCP/IP application port number 25 as the destination port, and will select at random a port from the dynamic or private range for the source port number. The remote server will normally respond by contacting the client system using the private port number as the destination and port number 25 as the source. In a typical SMTP session, a client system establishes a Telnet style conversation with a server, issues commands, and receives reply messages. Once the transmission channel is established, the client sends a MAIL command identifying the Sender of the mail message. If the server can accept mail it responds with an OK reply. The client then sends a RCPT command identifying the Recipient of the mail. If the server can accept mail for that recipient it responds with an OK reply; if not, it responds with a reply rejecting that recipient (but not the whole mail transaction). The client and server may negotiate several recipients for any individual mail message. When the recipients have been negotiated the client sends a DATA command, followed by the mail data, terminating with a special sequence. If the server successfully receives the mail data it responds with an OK reply. This dialog is purposely done in a lock-step, one-at-a-time sequence. The RCPT identifies both the destination Host and the Mail Box of the recipient. This E-Mail address gives the mail box first, as a text name, followed by an “@”, followed by the domain name of the host (e.g. BillGates@Microsoft.Com). The MAIL command identifies the source host and mail box of the sender using the same format. When the same message is to be sent to multiple recipients, the SMTP specification encourages the data to be sent one time with multiple RCPT commands to identify the recipients. SMTP provides a mechanism that allows mail to be sent directly from sender to recipient, or through intermediate hosts if there is no direct path from one to the other. Intermediate hosts may hold the message and try to pass it on towards the destination several times. If the message is not deliverable, a message to that effect is generated back to the sender. The mail commands and replies have a rigid syntax. Commands are four character abbreviations that may be followed by arguments. Replies are a three digit numeric code followed by a text message. The numeric code is designed to make it easier for the reply messages to be processed by a program. The text of the reply message also indicates success or failure, or gives information in addition to the numeric code. The SMTP protocol does require that all commands be implemented on all servers. There is a minimum command set that allows for compatibility between systems. For a full description of all SMTP commands and syntax, please see RFC 821. The following are commonly implemented SMTP commands:
An SMTP reply code consists of three digits, and is intended to make it easier for a program that is communicating with an FTP server to determine the result of the previous operation. The first digit tells whether the response if Good, Bad, or Incomplete. The second digit tells approximately what type of error occurred, and the third digit gives more specific information about the error. The following is a list of standard reply codes: 211 System status, or system help reply 214 Help message 220 (domain) Service ready 221 (domain) Service closing transmission channel 250 Requested mail action okay, completed 251 User not local; will forward to (forward-path) 354 Start mail input; end with (CRLF).(CRLF) 421 (domain) Service not available, 450 Requested mail action not taken: mailbox unavailable 451 Requested action aborted: local error in processing 452 Requested action not taken: insufficient system storage 500 Syntax error, command unrecognized 501 Syntax error in parameters or arguments 502 Command not implemented 503 Bad sequence of commands 504 Command parameter not implemented 550 Requested action not taken: mailbox unavailable 551 User not local; please try “forward-path” 552 Requested mail action aborted: exceeded storage allocation 553 Requested action not taken: mailbox name not allowed 554 Transaction failed
If a user does not have an SMTP client application, or for the purposes of testing and troubleshooting, it is possible to use a Telnet client application to contact an SMTP server and send mail messages. This is done by Telnetting to port 25 and entering the commands by hand. For example, the following is an example of sending a test message to the Postmaster at the imaginary destination Mail.ZZZ.Com. # telnet Mail.ZZZ.Com 25 Trying 192.168.10.1... Connected to mail.zzz.com. Escape character is '^]'. 220-zzz.com Sendmail 8.6.11/8.6.9 ready 220 ESMTP spoken here HELO xyz.com 250 zzz.com Hello joe.xyz.com [192.168.99.7] MAIL FROM: JoeS@XYZ.Com 250 JoeS@XYZ.Com... Sender ok RCPT TO: Postmaster@XYZ.Com 250 Postmaster@XYZ.Com... Recipient ok DATA 354 Enter mail, end with "." This is a test 1 2 3 4 5 6 7 8 9 . 250 MAA27083 Message accepted for delivery QUIT 221 zzz.com closing connection Connection closed by foreign host. # For more information on the SMTP protocol, see RFC 821.
|