Simple Mail Transfer Protocol
|
Application layer | HTTP, HTTPS, SMTP, FTP, UUCP, NNTP, SSH, IRC, SNMP, SIP, RTP, Telnet ,... |
Transport layer | TCP, UDP, SCTP, DCCP, ... |
Network layer | IPv4, IPv6, ICMP, ARP, IGMP, ... |
Data link layer | Ethernet, Wi-Fi, Token ring, FDDI, PPP, ... |
Physical layer | RS-232, EIA-422, RS-449, EIA-485... |
Simple Mail Transfer Protocol (SMTP) is the de facto standard for email transmission across the Internet.
SMTP is a relatively simple, text-based protocol, where one or more recipients of a message are specified (and in most cases verified to exist) and then the message text is transferred. It is quite easy to test a SMTP server using the telnet program. SMTP uses TCP port 25. To determine the SMTP server for a given domain name, the MX (Mail eXchange) DNS record is used.
SMTP started becoming widely used in the early 1980s. At the time, it was a complement to UUCP which was better suited to handle e-mail transfers between machines that were intermittently connected. SMTP, on the other hand, works best when both the sending and receiving machines are connected to the network all the time.
Sendmail was one of the first (if not the first) mail transfer agents to implement SMTP. As of 2001 there are at least 50 programs that implement SMTP as a client (sender of messages) or a server (receiver of messages). Some other popular SMTP server programs include Philip Hazel's exim, IBM's Postfix, D. J. Bernstein's Qmail, and Microsoft Exchange Server.
Since this protocol started out as purely ASCII text-based, it did not deal well with binary files. Standards such as MIME were developed to encode binary files for transfer through SMTP. Today, most SMTP servers support the 8BITMIME extension, permitting binary files to be transmitted almost as easily as plain text.
SMTP is a "push" protocol that does not allow one to "pull" messages from a remote server on demand. To do this a mail client must use POP3 or IMAP. Another SMTP server can trigger a delivery in SMTP using ETRN.
Contents |
Example SMTP communication
After establishing a connection between the sender (the client) and the receiver (the server), the following is a legal SMTP session. In the following conversation, everything sent by the client is prefaced with "C:" and everything sent by the server is prefaced with "S:". On most computer systems, a connection can be established using the telnet command on the sending machine, for example
telnet www.example.com 25
which opens an SMTP connection from the sending machine to the host www.example.com.
S: 220 www.example.com ESMTP Postfix C: HELO mydomain.com S: 250 Hello mydomain.com C: MAIL FROM: <sender@mydomain.com> S: 250 Ok C: RCPT TO: <friend@example.com> S: 250 Ok C: DATA S: 354 End data with <CR><LF>.<CR><LF> C: Subject: test message C: From: sender@mydomain.com C: To: friend@example.com C: C: Hello, C: This is a test. C: Goodbye. C: . S: 250 Ok: queued as 12345 C: quit S: 221 Bye
Although optional and not shown above, nearly all clients ask the server which SMTP extensions the server supports by using the EHLO greeting. These clients use HELO only if the server does not respond to EHLO.
SMTP security and spamming
One of the limitations of the original SMTP is that it has no facility for authentication of senders. Therefore the SMTP-AUTH extension was defined.
In spite of this, E-mail spamming is still a major problem. Modifying SMTP extensively, or replacing it completely, is not believed to be practical, due to the network effects of the huge installed base of SMTP. Internet Mail 2000 is one such proposal for replacement.
For this reason, there are a number of proposals for sideband protocols that will assist SMTP operation. The Anti-Spam Research Group of the IRTF is working on a number of proposals for providing simple source authentication that is flexible, lightweight, and scalable. The most likely proposal to be accepted is the Sender Policy Framework (formerly known as Sender Permitted From). However, SPF is currently in jeopardy as the current specification contains sections encumbered by Microsoft patents.
Basic SMTP Commands
HELO - Identify the SMTP sender to the SMTP receiver.
MAIL - Start an e-mail transaction to deliver the e-mail to one or more recipients.
RCPT - Identify an individual recipient of e-mail.
DATA - Consider the lines following the command to be e-mail from the sender.
SEND - Deliver e-mail to one or more work stations.
SOML - Deliver e-mail to one or more work stations or recipients if the user is not active.
SAML - Deliver e-mail to one or more work stations and recipients if the user is not active.
RSET - End the current e-mail transaction.
VRFY - Ask the receiver to confirm that a user has been identified.
EXPN - Ask the receiver to confirm that a mailing list has been identified.
HELP - Ask the receiver to send helpful information to the sender.
NOOP - Ask the receiver to send a valid reply (but specify no other action).
QUIT - Ask the receiver to send a valid reply, and then close the transmission channel.
TURN - Ask the receiver to send a valid reply and then become the SMTP sender, or else ask the receiver to send a refusal reply and remain the SMTP receiver.
SMTP Error Codes
421 Service not available, closing transmission channel (This may be a reply to any command if the service knows it must shut down)
450 Requested mail action not taken: mailbox unavailable (E.g., mailbox busy)
451 Requested action aborted: local error in processing
452 Requested action not taken: insufficient system storage
500 Syntax error, command unrecognized (This may include errors such as command line too long)
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 (E.g., mailbox not found, no access)
551 User not local; please try
552 Requested mail action aborted: exceeded storage allocation
553 Requested action not taken: mailbox name not allowed (E.g., mailbox syntax incorrect)
554 Transaction failed
The other codes that provide you with helpful information about what's happening with your messages are:
211 System status, or system help reply
214 Help message (Information on how to use the receiver or the meaning of a particular non-standard command; this reply is useful only to the human user)
220 Service ready
221 Service closing transmission channel
250 Requested mail action okay, completed
251 User not local; will forward to
354 Start mail input; end with . (a dot)
See also
Related RFCs
- RFC 2821 - The Simple Mail Transfer Protocol, which recently (2001) obsoleted RFC 821
- RFC 2822 - Internet (i.e. e-mail) Message Format, which obsoletes RFC 822
- RFC 1869 - Defines the capability for SMTP service extensions, creating Extended SMTP, or ESMTP
- RFC 1891 - Delivery Status Notification (DSN) extension to SMTP
External links
- RFC 2821, RFC2821 in html format (http://www.rfcsearch.org/rfcview/RFC/2821.html)
- SMTP Sequence Diagram (http://www.eventhelix.com/RealtimeMantra/Networking/SMTP_Sequence_Diagram.pdf)
- Domain Mail Server/Exchanger (MX Records) Lookup (http://www.hashemian.com/tools/domain-email.php)cs:SMTP
da:Simple Mail Transfer Protocol de:Simple Mail Transfer Protocol es:SMTP eo:SMTP fr:Simple Mail Transfer Protocol gl:SMTP id:SMTP it:SMTP he:SMTP ku:SMTP nl:Simple Mail Transfer Protocol ja:Simple Mail Transfer Protocol no:Simple Mail Transfer Protocol pl:SMTP pt:Simple Mail Transfer Protocol ru:SMTP fi:SMTP sv:SMTP uk:SMTP zh:SMTP