Recent from talks
Nothing was collected or created yet.
Simple Mail Transfer Protocol
View on Wikipedia
| Communication protocol | |
| Abbreviation | SMTP |
|---|---|
| Purpose | Electronic mail transmission protocol |
| Introduction | November 1981 |
| OSI layer | Application layer |
| Port(s) | 465, 587, 25 |
| RFC(s) | 5321 |
| Internet protocol suite |
|---|
| Application layer |
| Transport layer |
| Internet layer |
| Link layer |
The Simple Mail Transfer Protocol (SMTP) is an Internet standard communication protocol for electronic mail transmission. Mail servers and other message transfer agents use SMTP to send and receive mail messages. User-level email clients typically use SMTP only for sending messages to a mail server for relaying, and typically submit outgoing email to the mail server on port 465 or 587 per RFC 8314. For retrieving messages, IMAP (which replaced the older POP3) is standard, but proprietary servers also often implement proprietary protocols, e.g., Exchange ActiveSync.
SMTP's origins began in 1980, building on concepts implemented on the ARPANET since 1971. It has been updated, modified and extended multiple times. The protocol version in common use today has extensible structure with various extensions for authentication, encryption, binary data transfer, and internationalized email addresses. SMTP servers commonly use the Transmission Control Protocol on port number 25 (between servers) and 587 (for submission from authenticated clients), both with or without encryption, and 465 with encryption for submission.
History
[edit]Predecessors to SMTP
[edit]Various forms of one-to-one electronic messaging were used in the 1960s. Users communicated using systems developed for specific mainframe computers. As more computers were interconnected, especially in the U.S. Government's ARPANET, standards were developed to permit exchange of messages between different operating systems.
Mail on the ARPANET traces its roots to 1971: the Mail Box Protocol, which was not implemented,[1] but is discussed in RFC 196; and the SNDMSG program, which Ray Tomlinson of BBN adapted that year to send messages across two computers on the ARPANET.[2][3][4] A further proposal for a Mail Protocol was made in RFC 524 in June 1973,[5] which was not implemented.[6]
The use of the File Transfer Protocol (FTP) for "network mail" on the ARPANET was proposed in RFC 469 in March 1973.[7] Through RFC 561, RFC 680, RFC 724, and finally RFC 733 in November 1977, a standardized framework for "electronic mail" using FTP mail servers on was developed.[8][9]
SMTP grew out of these standards developed during the 1970s. Ray Tomlinson discussed network mail among the International Network Working Group in INWG Protocol note 2, written in September 1974.[10] INWG discussed protocols for electronic mail in 1979,[11] which was referenced by Jon Postel in his early work on Internet email. Postel first proposed an Internet Message Protocol in 1979 as part of the Internet Experiment Note (IEN) series.[12][13][14]
Original SMTP
[edit]In 1980, Postel and Suzanne Sluizer published RFC 772 which proposed the Mail Transfer Protocol as a replacement for the use of the FTP for mail. RFC 780 of May 1981 removed all references to FTP and allocated port 57 for TCP and UDP,[15] an allocation that has since been removed by IANA. In November 1981, Postel published RFC 788 "Simple Mail Transfer Protocol".
The SMTP standard was developed around the same time as Usenet, a one-to-many communication network with some similarities.[15]
SMTP became widely used in the early 1980s. At the time, it was a complement to the Unix to Unix Copy Program (UUCP), which was better suited for handling email 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. Both used a store and forward mechanism and are examples of push technology. Though Usenet's newsgroups were still propagated with UUCP between servers,[16] UUCP as a mail transport has virtually disappeared[17] along with the "bang paths" it used as message routing headers.[18]
Sendmail, released with 4.1cBSD in 1983, was one of the first mail transfer agents (MTA) to implement SMTP.[19] Over time, as BSD Unix became the most popular operating system on the Internet, Sendmail became the most common mail transfer agent.[20]
The original SMTP protocol supported only unauthenticated unencrypted 7-bit ASCII text communications, susceptible to trivial man-in-the-middle attack, spoofing, and spamming, and requiring any binary data to be encoded to readable text before transmission. Due to absence of a proper authentication mechanism, by design every SMTP server was an open mail relay. The Internet Mail Consortium (IMC) reported that 55% of mail servers were open relays in 1998,[21] but less than 1% in 2002.[22] Because of spam concerns most email providers blocklist open relays,[23] making original SMTP essentially impractical for general use on the Internet.
Modern SMTP
[edit]In November 1995, RFC 1869 defined Extended Simple Mail Transfer Protocol (ESMTP), which established a general structure for all existing and future extensions which aimed to add-in the features missing from the original SMTP. ESMTP defines consistent and manageable means by which ESMTP clients and servers can be identified and servers can indicate supported extensions.
Message submission (RFC 2476) and SMTP-AUTH (RFC 2554) were introduced in 1998 and 1999, both describing new trends in email delivery. Originally, SMTP servers were typically internal to an organization, receiving mail for the organization from the outside, and relaying messages from the organization to the outside. But as time went on, SMTP servers (mail transfer agents), in practice, were expanding their roles to become message submission agents for mail user agents, some of which were now relaying mail from the outside of an organization. (e.g. a company executive wishes to send email while on a trip using the corporate SMTP server.) This issue, a consequence of the rapid expansion and popularity of the World Wide Web, meant that SMTP had to include specific rules and methods for relaying mail and authenticating users to prevent abuses such as relaying of unsolicited email (spam). Work on message submission (RFC 2476) was originally started because popular mail servers would often rewrite mail in an attempt to fix problems in it, for example, adding a domain name to an unqualified address. This behavior is helpful when the message being fixed is an initial submission, but dangerous and harmful when the message originated elsewhere and is being relayed. Cleanly separating mail into submission and relay was seen as a way to permit and encourage rewriting submissions while prohibiting rewriting relay. As spam became more prevalent, it was also seen as a way to provide authorization for mail being sent out from an organization, as well as traceability. This separation of relay and submission quickly became a foundation for modern email security practices.
As this protocol started out purely ASCII text-based, it did not deal well with binary files, or characters in many non-English languages. Standards such as Multipurpose Internet Mail Extensions (MIME) were developed to encode binary files for transfer through SMTP. Mail transfer agents (MTAs) developed after Sendmail also tended to be implemented 8-bit clean, so that the alternate "just send eight" strategy could be used to transmit arbitrary text data (in any 8-bit ASCII-like character encoding) via SMTP. Mojibake was still a problem due to differing character set mappings between vendors, although the email addresses themselves still allowed only ASCII. 8-bit-clean MTAs today tend to support the 8BITMIME extension, permitting some binary files to be transmitted almost as easily as plain text (limits on line length and permitted octet values still apply, so that MIME encoding is needed for most non-text data and some text formats). In 2012, the SMTPUTF8 extension was created to support UTF-8 text, allowing international content and addresses in non-Latin scripts like Cyrillic or Chinese.
Many people contributed to the core SMTP specifications, among them Jon Postel, Eric Allman, Dave Crocker, Ned Freed, Randall Gellens, John Klensin, and Keith Moore.
Mail processing model
[edit]
Email is submitted by a mail client (mail user agent, MUA) to a mail server (mail submission agent, MSA) using SMTP on TCP port 465 or 587. Most mailbox providers still allow submission on traditional port 25. The MSA delivers the mail to its mail transfer agent (MTA). Often, these two agents are instances of the same software launched with different options on the same machine. Local processing can be done either on a single machine, or split among multiple machines; mail agent processes on one machine can share files, but if processing is on multiple machines, they transfer messages between each other using SMTP, where each machine is configured to use the next machine as a smart host. Each process is an MTA (an SMTP server) in its own right.
The boundary MTA uses DNS to look up the MX (mail exchanger) record for the recipient's domain (the part of the email address on the right of @). The MX record contains the name of the target MTA. Based on the target host and other factors, the sending MTA selects a recipient server and connects to it to complete the mail exchange.
Message transfer can occur in a single connection between two MTAs, or in a series of hops through intermediary systems. A receiving SMTP server may be the ultimate destination, an intermediate "relay" (that is, it stores and forwards the message) or a "gateway" (that is, it may forward the message using some protocol other than SMTP). Per RFC 5321 section 2.1, each hop is a formal handoff of responsibility for the message, whereby the receiving server must either deliver the message or properly report the failure to do so.
Once the final hop accepts the incoming message, it hands it to a mail delivery agent (MDA) for local delivery. An MDA saves messages in the relevant mailbox format. As with sending, this reception can be done using one or multiple computers, but in the diagram above the MDA is depicted as one box near the mail exchanger box. An MDA may deliver messages directly to storage, or forward them over a network using SMTP or other protocol such as Local Mail Transfer Protocol (LMTP), a derivative of SMTP designed for this purpose.
Once delivered to the local mail server, the mail is stored for batch retrieval by authenticated mail clients (MUAs). Mail is retrieved by end-user applications, called email clients, using Internet Message Access Protocol (IMAP), a protocol that both facilitates access to mail and manages stored mail, or the Post Office Protocol (POP) which typically uses the traditional mbox mail file format or a proprietary system such as Microsoft Exchange/Outlook or Lotus Notes/Domino. Webmail clients may use either method, but the retrieval protocol is often not a formal standard.
SMTP defines message transport, not the message content. Thus, it defines the mail envelope and its parameters, such as the envelope sender, but not the header (except trace information) nor the body of the message itself. STD 10 and RFC 5321 define SMTP (the envelope), while STD 11 and RFC 5322 define the message (header and body), formally referred to as the Internet Message Format.
Protocol overview
[edit]SMTP is a connection-oriented, text-based protocol in which a mail sender communicates with a mail receiver by issuing command strings and supplying necessary data over a reliable ordered data stream channel, typically a Transmission Control Protocol (TCP) connection. An SMTP session consists of commands originated by an SMTP client (the initiating agent, sender, or transmitter) and corresponding responses from the SMTP server (the listening agent, or receiver) so that the session is opened, and session parameters are exchanged. A session may include zero or more SMTP transactions. An SMTP transaction consists of three command/reply sequences:
- MAIL command, to establish the return address, also called return-path,[24] reverse-path,[25] bounce address, mfrom, or envelope sender.
- RCPT command, to establish a recipient of the message. This command can be issued multiple times, one for each recipient. These addresses are also part of the envelope.
- DATA to signal the beginning of the message text; the content of the message, as opposed to its envelope. It consists of a message header and a message body separated by an empty line. DATA is actually a group of commands, and the server replies twice: once to the DATA command itself, to acknowledge that it is ready to receive the text, and the second time after the end-of-data sequence, to either accept or reject the entire message.
Besides the intermediate reply for DATA, each server's reply can be either positive (2xx reply codes) or negative. Negative replies can be permanent (5xx codes) or transient (4xx codes). A reject is a permanent failure and the client should send a bounce message to the server it received it from. A drop is a positive response followed by message discard rather than delivery.
The initiating host, the SMTP client, can be either an end-user's email client, functionally identified as a mail user agent (MUA), or a relay server's mail transfer agent (MTA), that is an SMTP server acting as an SMTP client, in the relevant session, in order to relay mail. Fully capable SMTP servers maintain queues of messages for retrying message transmissions that resulted in transient failures.
A MUA knows the outgoing mail SMTP server from its configuration. A relay server typically determines which server to connect to by looking up the MX (Mail eXchange) DNS resource record for each recipient's domain name. If no MX record is found, a conformant relaying server (not all are) instead looks up the A record. Relay servers can also be configured to use a smart host. A relay server initiates a TCP connection to the server on the "well-known port" for SMTP: port 25, or for connecting to an MSA, port 465 or 587. The main difference between an MTA and an MSA is that connecting to an MSA requires SMTP Authentication.
SMTP vs mail retrieval
[edit]SMTP is a delivery protocol only. In normal use, mail is "pushed" to a destination mail server (or next-hop mail server) as it arrives. Mail is routed based on the destination server, not the individual user(s) to which it is addressed. Other protocols, such as the Post Office Protocol (POP) and the Internet Message Access Protocol (IMAP) are specifically designed for use by individual users retrieving messages and managing mailboxes. To permit an intermittently-connected mail server to pull messages from a remote server on demand, SMTP has a feature to initiate mail queue processing on a remote server (see Remote Message Queue Starting below). POP and IMAP are unsuitable protocols for relaying mail by intermittently-connected machines; they are designed to operate after final delivery, when information critical to the correct operation of mail relay (the "mail envelope") has been removed.
Remote Message Queue Starting
[edit]Remote Message Queue Starting enables a remote host to start processing of the mail queue on a server so it may receive messages destined to it by sending a corresponding command. The original TURN command was deemed insecure and was extended in RFC 1985 with the ETRN command which operates more securely using an authentication method based on Domain Name System information.[26]
Outgoing mail SMTP server
[edit]An email client needs to know the IP address of its initial SMTP server and this has to be given as part of its configuration (usually given as a DNS name). This server will deliver outgoing messages on behalf of the user.
Outgoing mail server access restrictions
[edit]Server administrators need to impose some control on which clients can use the server. This enables them to deal with abuse, for example spam. Two solutions have been in common use:
- In the past, many systems imposed usage restrictions by the location of the client, only permitting usage by clients whose IP address is one that the server administrators control. Usage from any other client IP address is disallowed.
- Modern SMTP servers typically offer an alternative system that requires authentication of clients by credentials before allowing access.
Restricting access by location
[edit]Under this system, an ISP's SMTP server will not allow access by users who are outside the ISP's network. More precisely, the server may only allow access to users with an IP address provided by the ISP, which is equivalent to requiring that they are connected to the Internet using that same ISP. A mobile user may often be on a network other than that of their normal ISP, and will then find that sending email fails because the configured SMTP server choice is no longer accessible.
This system has several variations. For example, an organisation's SMTP server may only provide service to users on the same network, enforcing this by firewalling to block access by users on the wider Internet. Or the server may perform range checks on the client's IP address. These methods were typically used by corporations and institutions such as universities which provided an SMTP server for outbound mail only for use internally within the organisation. However, most of these bodies now use client authentication methods, as described below.
Where a user is mobile, and may use different ISPs to connect to the internet, this kind of usage restriction is onerous, and altering the configured outbound email SMTP server address is impractical. It is highly desirable to be able to use email client configuration information that does not need to change.
Client authentication
[edit]Modern SMTP servers typically require authentication of clients by credentials before allowing access, rather than restricting access by location as described earlier. This more flexible system is friendly to mobile users and allows them to have a fixed choice of configured outbound SMTP server. SMTP Authentication, often abbreviated SMTP AUTH, is an extension of the SMTP in order to log in using an authentication mechanism.
Ports
[edit]Communication between mail servers generally uses the standard TCP port 25 designated for SMTP.
Mail clients however generally don't use this, instead using specific "submission" ports. Mail services generally accept email submission from clients on one of:
- 465 This port was deprecated after RFC 2487, until the issue of RFC 8314.
- 587 (Submission), as formalized in RFC 6409 (previously RFC 2476)
Port 2525 and others may be used by some individual providers, but have never been officially supported.
Many Internet service providers now block all outgoing port 25 traffic from their customers. Mainly as an anti-spam measure,[27] but also to cure for the higher cost they have when leaving it open, perhaps by charging more from the few customers that require it open.
SMTP transport example
[edit]A typical example of sending a message via SMTP to two mailboxes (alice and theboss) located in the same mail domain (example.com) is reproduced in the following session exchange. (In this example, the conversation parts are prefixed with S: and C:, for server and client, respectively; these labels are not part of the exchange.)
After the message sender (SMTP client) establishes a reliable communications channel to the message receiver (SMTP server), the session is opened with a greeting by the server, usually containing its fully qualified domain name (FQDN), in this case smtp.example.com. The client initiates its dialog by responding with a HELO command identifying itself in the command's parameter with its FQDN (or an address literal if none is available).[28]
S: 220 smtp.example.com ESMTP Postfix C: HELO relay.example.org S: 250 Hello relay.example.org, I am glad to meet you C: MAIL FROM:<bob@example.org> S: 250 Ok C: RCPT TO:<alice@example.com> S: 250 Ok C: RCPT TO:<theboss@example.com> S: 250 Ok C: DATA S: 354 End data with <CR><LF>.<CR><LF> C:From: "Bob Example" <bob@example.org>C:To: "Alice Example" <alice@example.com>C:Cc: theboss@example.comC:Date: Tue, 15 Jan 2008 16:02:43 -0500C:Subject: Test messageC: C: Hello Alice. C: This is a test message with 5 header fields and 4 lines in the message body. C: Your friend, C: Bob C: . S: 250 Ok: queued as 12345 C: QUIT S: 221 Bye {The server closes the connection}
The client notifies the receiver of the originating email address of the message in a MAIL FROM command. This is also the return or bounce address in case the message cannot be delivered. In this example the email message is sent to two mailboxes on the same SMTP server: one for each recipient listed in the To: and Cc: header fields. The corresponding SMTP command is RCPT TO. Each successful reception and execution of a command is acknowledged by the server with a result code and response message (e.g., 250 Ok).
The transmission of the body of the mail message is initiated with a DATA command after which it is transmitted verbatim line by line and is terminated with an end-of-data sequence. This sequence consists of a new-line (<CR><LF>), a single full stop (.), followed by another new-line (<CR><LF>). Since a message body can contain a line with just a period as part of the text, the client sends two periods every time a line starts with a period; correspondingly, the server replaces every sequence of two periods at the beginning of a line with a single one. Such escaping method is called dot-stuffing.
The server's positive reply to the end-of-data, as exemplified, implies that the server has taken the responsibility of delivering the message. A message can be doubled if there is a communication failure at this time, e.g. due to a power outage: Until the sender has received that 250 Ok reply, it must assume the message was not delivered. On the other hand, after the receiver has decided to accept the message, it must assume the message has been delivered to it. Thus, during this time span, both agents have active copies of the message that they will try to deliver.[29] The probability that a communication failure occurs exactly at this step is directly proportional to the amount of filtering that the server performs on the message body, most often for anti-spam purposes. The limiting timeout is specified to be 10 minutes.[30]
The QUIT command ends the session. If the email has other recipients located elsewhere, the client would QUIT and connect to an appropriate SMTP server for subsequent recipients after the current destination(s) had been queued. The information that the client sends in the HELO and MAIL FROM commands are added (not seen in example code) as additional header fields to the message by the receiving server. It adds a Received and Return-Path header field, respectively.
Some clients are implemented to close the connection after the message is accepted (250 Ok: queued as 12345), so the last two lines may actually be omitted. This causes an error on the server when trying to send the 221 Bye reply.
SMTP Extensions
[edit]Extension discovery mechanism
[edit]Clients learn a server's supported options by using the EHLO greeting, as exemplified below, instead of the original HELO. Clients fall back to HELO only if the server does not support EHLO greeting.[31]
Modern clients may use the ESMTP extension keyword SIZE to query the server for the maximum message size that will be accepted. Older clients and servers may try to transfer excessively sized messages that will be rejected after consuming network resources, including connect time to network links that is paid by the minute.[32]
Users can manually determine in advance the maximum size accepted by ESMTP servers. The client replaces the HELO command with the EHLO command.
S: 220 smtp2.example.com ESMTP Postfix C: EHLO bob.example.org S: 250-smtp2.example.com Hello bob.example.org [192.0.2.201] S: 250-SIZE 14680064 S: 250-PIPELINING S: 250 HELP
Thus smtp2.example.com declares that it can accept a fixed maximum message size no larger than 14,680,064 octets (8-bit bytes).
In the simplest case, an ESMTP server declares a maximum SIZE immediately after receiving an EHLO. According to RFC 1870, however, the numeric parameter to the SIZE extension in the EHLO response is optional. Clients may instead, when issuing a MAIL FROM command, include a numeric estimate of the size of the message they are transferring, so that the server can refuse receipt of overly-large messages.
Binary data transfer
[edit]Original SMTP supports only a single body of ASCII text, therefore any binary data needs to be encoded as text into that body of the message before transfer, and then decoded by the recipient. Binary-to-text encodings, such as uuencode and BinHex were typically used.
The 8BITMIME command was developed to address this. It was standardized in 1994 as RFC 1652[33] It facilitates the transparent exchange of e-mail messages containing octets outside the seven-bit ASCII character set by encoding them as MIME content parts, typically encoded with Base64.
On-Demand Mail Relay
[edit]On-Demand Mail Relay (ODMR) is an SMTP extension standardized in RFC 2645 that allows an intermittently-connected SMTP server to receive email queued for it when it is connected.
Internationalization extension
[edit]Original SMTP supports email addresses composed of ASCII characters only, which is inconvenient for users whose native script is not Latin based, or who use diacritic not in the ASCII character set. This limitation was alleviated via extensions enabling UTF-8 in address names. RFC 5336 introduced experimental[32] UTF8SMTP command and later was superseded by RFC 6531 that introduced SMTPUTF8 command. These extensions provide support for multi-byte and non-ASCII characters in email addresses, such as those with diacritics and other language characters such as Greek and Chinese.[34]
Current support is limited, but there is strong interest in broad adoption of RFC 6531 and the related RFCs in countries like China that have a large user base where Latin (ASCII) is a foreign script.
Extensions
[edit]Like SMTP, ESMTP is a protocol used to transport Internet mail. It is used as both an inter-server transport protocol and (with restricted behavior enforced) a mail submission protocol.
The main identification feature for ESMTP clients is to open a transmission with the command EHLO (Extended HELLO), rather than HELO (Hello, the original RFC 821 standard). A server will respond with success (code 250), failure (code 550) or error (code 500, 501, 502, 504, or 421), depending on its configuration. An ESMTP server returns the code 250 OK in a multi-line reply with its domain and a list of keywords to indicate supported extensions. A RFC 821 compliant server returns error code 500, allowing ESMTP clients to try either HELO or QUIT.
Each service extension is defined in an approved format in subsequent RFCs and registered with the Internet Assigned Numbers Authority (IANA). The first definitions were the RFC 821 optional services: SEND, SOML (Send or Mail), SAML (Send and Mail), EXPN, HELP, and TURN. The format of additional SMTP verbs was set and for new parameters in MAIL and RCPT.
Some relatively common keywords (not all of them corresponding to commands) used today are:
8BITMIME– 8 bit data transmission, RFC 6152ATRN– AuthenticatedTURNfor On-Demand Mail Relay, RFC 2645AUTH– Authenticated SMTP, RFC 4954CHUNKING– Chunking, RFC 3030DSN– Delivery status notification, RFC 3461 (See Variable envelope return path)ETRN– Extended version of remote message queue starting commandTURN, RFC 1985HELP– Supply helpful information, RFC 821PIPELINING– Command pipelining, RFC 2920SIZE– Message size declaration, RFC 1870STARTTLS– Transport Layer Security, RFC 3207 (2002)SMTPUTF8– Allow UTF-8 encoding in mailbox names and header fields, RFC 6531UTF8SMTP– Allow UTF-8 encoding in mailbox names and header fields, RFC 5336 (deprecated[35])
The ESMTP format was restated in RFC 2821 (superseding RFC 821) and updated to the latest definition in RFC 5321 in 2008. Support for the EHLO command in servers became mandatory, and HELO designated a required fallback.
Non-standard, unregistered, service extensions can be used by bilateral agreement, these services are indicated by an EHLO message keyword starting with "X", and with any additional parameters or verbs similarly marked.
SMTP commands are case-insensitive. They are presented here in capitalized form for emphasis only. An SMTP server that requires a specific capitalization method is a violation of the standard.[28]
8BITMIME
[edit]At least the following servers advertise the 8BITMIME extension:
- Apache James (since 2.3.0a1)[36]
- Citadel (since 7.30)
- Courier Mail Server
- Gmail[37]
- IceWarp
- IIS SMTP Service
- Kerio Connect
- Lotus Domino
- Microsoft Exchange Server (as of Exchange Server 2000)
- Novell GroupWise
- OpenSMTPD
- Oracle Communications Messaging Server
- Postfix
- Sendmail (since 6.57)
The following servers can be configured to advertise 8BITMIME, but do not perform conversion of 8-bit data to 7-bit when connecting to non-8BITMIME relays:
- Exim and qmail do not translate eight-bit messages to seven-bit when making an attempt to relay 8-bit data to non-8BITMIME peers, as is required by the RFC.[38] This does not cause problems in practice, since virtually all modern mail relays are 8-bit clean.[39]
- Microsoft Exchange Server 2003 advertises 8BITMIME by default, but relaying to a non-8BITMIME peer results in a bounce. This is allowed by RFC 6152.[40]
SMTP-AUTH
[edit]The SMTP-AUTH extension provides an access control mechanism. It consists of an authentication step through which the client effectively logs into the mail server during the process of sending mail. Servers that support SMTP-AUTH can usually be configured to require clients to use this extension, ensuring the true identity of the sender is known. The SMTP-AUTH extension is defined in RFC 4954.
SMTP-AUTH can be used to allow legitimate users to relay mail while denying relay service to unauthorized users, such as spammers. It does not necessarily guarantee the authenticity of either the SMTP envelope sender or the RFC 2822 "From:" header. For example, spoofing, in which one sender masquerades as someone else, is still possible with SMTP-AUTH unless the server is configured to limit message from-addresses to addresses this AUTHed user is authorized for.
The SMTP-AUTH extension also allows one mail server to indicate to another that the sender has been authenticated when relaying mail. In general this requires the recipient server to trust the sending server, meaning that this aspect of SMTP-AUTH is rarely used on the Internet.[citation needed]
SMTPUTF8
[edit]Supporting servers include:
- Postfix (version 3.0 and later)[41]
- Momentum (versions 4.1[42] and 3.6.5, and later)
- Sendmail (experimental support in 8.17.1)
- Exim (experimental as of the 4.86 release, quite mature in 4.96)
- CommuniGate Pro as of version 6.2.2[43]
- Courier-MTA as of version 1.0[44]
- Halon as of version 4.0[45]
- Microsoft Exchange Server as of protocol revision 14.0[46]
- Haraka and other servers.[47]
- Oracle Communications Messaging Server as of release 8.0.2.[48]
Security extensions
[edit]Mail delivery can occur both over plain text and encrypted connections, however the communicating parties might not know in advance of other party's ability to use secure channel.
STARTTLS or "Opportunistic TLS"
[edit]The STARTTLS extensions enables supporting SMTP servers to notify connecting clients that it supports TLS encrypted communication and offers the opportunity for clients to upgrade their connection by sending the STARTTLS command. Servers supporting the extension do not inherently gain any security benefits from its implementation on its own, as upgrading to a TLS encrypted session is dependent on the connecting client deciding to exercise this option, hence the term opportunistic TLS.
STARTTLS is effective only against passive observation attacks, since the STARTTLS negotiation happens in plain text and an active attacker can trivially remove STARTTLS commands. This type of man-in-the-middle attack is sometimes referred to as STRIPTLS, where the encryption negotiation information sent from one end never reaches the other. In this scenario both parties take the invalid or unexpected responses as indication that the other does not properly support STARTTLS, defaulting to traditional plain-text mail transfer.[49] Note that STARTTLS is also defined for IMAP and POP3 in other RFCs, but these protocols serve different purposes: SMTP is used for communication between message transfer agents, while IMAP and POP3 are for end clients and message transfer agents.
In 2014 the Electronic Frontier Foundation began "STARTTLS Everywhere" project that, similarly to "HTTPS Everywhere" list, allowed relying parties to discover others supporting secure communication without prior communication. The project stopped accepting submissions on 29 April 2021, and EFF recommended switching to DANE and MTA-STS for discovering information on peers' TLS support.[50]
RFC 8314 officially declared plain text obsolete and recommend always using TLS for mail submission and access, adding ports with implicit TLS.
DANE for SMTP
[edit]RFC 7672 introduced the ability for DNS records to declare the encryption capabilities of a mail server. Utilising DNSSEC, mail server operators are able to publish a hash of their TLS certificate, thereby mitigating the possibility of unencrypted communications.[51]
Microsoft expects to enable full SMTP DANE support for Exchange Online customers by the end of 2024.[52]
SMTP MTA Strict Transport Security
[edit]A newer 2018 RFC 8461 called "SMTP MTA Strict Transport Security (MTA-STS)" aims to address the problem of active adversaries by defining a protocol for mail servers to declare their ability to use secure channels in specific files on the server and specific DNS TXT records. The relying party would regularly check existence of such record, and cache it for the amount of time specified in the record and never communicate over insecure channels until record expires.[49] Note that MTA-STS records apply only to SMTP traffic between mail servers while communications between a user's client and the mail server are protected by Transport Layer Security with SMTP/MSA, IMAP, POP3, or HTTPS in combination with an organizational or technical policy. Essentially, MTA-STS is a means to extend such a policy to third parties.
In April 2019 Google Mail announced support for MTA-STS.[53]
SMTP TLS Reporting
[edit]Protocols designed to securely deliver messages can fail due to misconfigurations or deliberate active interference, leading to undelivered messages or delivery over unencrypted or unauthenticated channels. RFC 8460 "SMTP TLS Reporting" describes a reporting mechanism and format for sharing statistics and specific information about potential failures with recipient domains. Recipient domains can then use this information to both detect potential attacks and diagnose unintentional misconfigurations.
In April 2019 Google Mail announced support for SMTP TLS Reporting.[53]
Spoofing and spamming
[edit]The original design of SMTP had no facility to authenticate senders, or check that servers were authorized to send on their behalf, with the result that email spoofing is possible, and commonly used in email spam and phishing.
Occasional proposals are made to modify SMTP extensively or replace it completely. One example of this is Internet Mail 2000, but neither it, nor any other has made much headway in the face of the network effect of the huge installed base of classic SMTP.
Instead, mail servers now use a range of techniques, such as stricter enforcement of standards such as RFC 5322,[54][55] DomainKeys Identified Mail, Sender Policy Framework and DMARC, DNSBLs and greylisting to reject or quarantine suspicious emails.[56]
Implementations
[edit]See also
[edit]- Bounce address
- CRAM-MD5 (a SASL mechanism for ESMTPA) RFC 2195
- DKIM
- Ident
- List of mail server software
- List of SMTP server return codes
- POP before SMTP / SMTP after POP
- Internet Message Access Protocol Binary Content Extension RFC 3516
- Sender Policy Framework (SPF)
- Simple Authentication and Security Layer (SASL) RFC 4422
- SMTP Authentication
- Variable envelope return path
- Comparison of email clients for information about SMTP support
Notes
[edit]- ^ The History of Electronic Mail Archived December 2, 2017, at the Wayback Machine, Tom Van Vleck: "It is not clear this protocol was ever implemented"
- ^ The First Network Email, Ray Tomlinson, BBN
- ^ Picture of "The First Email Computer" by Dan Murphy, a PDP-10
- ^ Dan Murphy's TENEX and TOPS-20 Papers Archived November 18, 2007, at the Wayback Machine
- ^ RFC 524 – A Proposed Mail Protocol
- ^ Crocker, David H. (December 1977). "Framework and Functions of the "MS" Personal Message System" (PDF). The RAND Corporation. Archived (PDF) from the original on May 13, 2022. Retrieved April 17, 2022.
- ^ RFC 469 – Network Mail Meeting Summary
- ^ RFC 733, 21 November 1977, Standard for the Format of ARPA Network Text Message
- ^ "A history of e-mail: Collaboration, innovation and the birth of a system". Washington Post. May 20, 2023. ISSN 0190-8286. Retrieved July 7, 2024.
- ^ McKenzie, Alexander (2011). "INWG and the Conception of the Internet: An Eyewitness Account". IEEE Annals of the History of Computing. 33 (1): 66–71. doi:10.1109/MAHC.2011.9. ISSN 1934-1547. S2CID 206443072.
- ^ Barber, D., and J. Laws, "A Basic Mail Scheme for EIN," INWG 192, February 1979.
- ^ IEN 85.
- ^ IEN 113.
- ^ "Internet Experiment Note Index". www.rfc-editor.org. Retrieved July 7, 2024.
- ^ a b Postel, J. (August 1982). Simple Mail Transfer Protocol (Report). RFC Editor.
- ^ "Tldp.org". Archived from the original on August 17, 2007. Retrieved August 25, 2007.
- ^ Barber, Stan O. (December 19, 2000). "draft-barber-uucp-project-conclusion-05 – The Conclusion of the UUCP Mapping Project". Archived from the original on October 13, 2007. Retrieved August 25, 2007.
- ^ The article about sender rewriting contains technical background info about the early SMTP history and source routing before RFC 1123.
- ^ Eric Allman (1983), Sendmail – An Internetwork Mail Router (PDF), BSD UNIX documentation set, Berkeley: University of California, archived (PDF) from the original on May 20, 2013, retrieved June 29, 2012
- ^ Craig Partridge (2008), The Technical Development of Internet Email (PDF), IEEE Annals of the History of Computing, vol. 30, IEEE Computer Society, pp. 3–29, doi:10.1109/MAHC.2008.32, S2CID 206442868, archived from the original (PDF) on May 12, 2011
- ^ Paul Hoffman (February 1, 1998). "Allowing Relaying in SMTP: A Survey". Internet Mail Consortium. Archived from the original on March 5, 2016. Retrieved May 30, 2010.
- ^ Paul Hoffman (August 2002). "Allowing Relaying in SMTP: A Series of Surveys". Internet Mail Consortium. Archived from the original on January 18, 2007. Retrieved May 30, 2010.
- ^ "In Unix, what is an open mail relay? - Knowledge Base". June 17, 2007. Archived from the original on June 17, 2007. Retrieved March 15, 2021.
- ^ "The MAIL, RCPT, and DATA verbs" Archived February 22, 2014, at the Wayback Machine, [D. J. Bernstein]
- ^ RFC 5321 Section-7.2
- ^ Systems, Message. "Message Systems Introduces Latest Version Of Momentum With New API-Driven Capabilities". www.prnewswire.com (Press release). Archived from the original on July 19, 2020. Retrieved July 19, 2020.
- ^ Cara Garretson (2005). "ISPs Pitch In to Stop Spam". PC World. Archived from the original on August 28, 2015. Retrieved January 18, 2016.
Last month, the Anti-Spam Technical Alliance, formed last year by Yahoo, America Online, EarthLink, and Microsoft, issued a list of antispam recommendations that includes filtering Port 25.
- ^ a b J. Klensin (October 2008). Simple Mail Transfer Protocol. IETF Network Working Group. doi:10.17487/RFC5321. RFC 5321. Draft Standard. Updated by RFC 7504. Obsoletes RFC 2821. Updates RFC 1123.
- ^ RFC 1047
- ^ Klensin, John C. (October 2008). "DATA Termination: 10 Minutes.". Simple Mail Transfer Protocol. sec. 4.5.3.2.6. doi:10.17487/RFC5321. RFC 5321. Retrieved June 7, 2010.
- ^ John Klensin; Ned Freed; Marshall T. Rose; Einar A. Stefferud; Dave Crocker (November 1995). SMTP Service Extensions. IETF. doi:10.17487/RFC1869. RFC 1869.
- ^ a b "MAIL Parameters". IANA. February 14, 2020. Archived from the original on May 28, 2019. Retrieved May 28, 2019.
- ^ Which was obsoleted in 2011 by RFC 6152 corresponding to the then new STD 71
- ^ Jiankang Yao (December 19, 2014). "Chinese email address". EAI (Mailing list). IETF. Archived from the original on October 2, 2015. Retrieved May 24, 2016.
- ^ "SMTP Service Extension Parameters". IANA. Archived from the original on May 28, 2019. Retrieved November 5, 2013.
- ^ James Server - ChangeLog Archived February 20, 2020, at the Wayback Machine. James.apache.org. Retrieved on 2013-07-17.
- ^ 8BITMIME service advertised in response to EHLO on gmail-smtp-in.l.google.com port 25, checked 23 November 2011
- ^ Qmail bugs and wishlist. Home.pages.de. Retrieved on 2013-07-17.
- ^ The 8BITMIME extension Archived June 7, 2011, at the Wayback Machine. Cr.yp.to. Retrieved on 2013-07-17.
- ^ "The 8bit-MIMEtransport Service Extension". SMTP Service Extension for 8-bit MIME Transport. March 2011. sec. 3. doi:10.17487/RFC6152. RFC 6152.
- ^ "Postfix SMTPUTF8 support is enabled by default" Archived August 7, 2020, at the Wayback Machine, February 8, 2015, postfix.org
- ^ "Message Systems Introduces Latest Version Of Momentum With New API-Driven Capabilities" (Press release). Archived from the original on September 15, 2020. Retrieved September 17, 2020.
- ^ "Version 6.2 Revision History". CommuniGate.com. Archived from the original on October 29, 2020. Retrieved September 17, 2020.
- ^ Sam Varshavchik (September 18, 2018). "New releases of Courier packages". courier-announce (Mailing list). Archived from the original on August 17, 2021. Retrieved September 17, 2020.
- ^ "Halon MTA changelog". GitHub. November 9, 2021. Archived from the original on September 18, 2020. Retrieved September 17, 2020.
v4.0: New SMTPUTF8 support
Updated for new versions - ^ "MS-OXSMTP: Simple Mail Transfer Protocol (SMTP) Extensions". July 24, 2018. Archived from the original on August 16, 2021. Retrieved September 17, 2020.
- ^ "EAI Readiness in TLDs" (PDF). February 12, 2019. Archived (PDF) from the original on January 24, 2021. Retrieved September 17, 2020.
- ^ "Communications Messaging Server Release Notes". oracle.com. October 2017. Archived from the original on November 24, 2020. Retrieved September 17, 2020.
- ^ a b "Introducing MTA Strict Transport Security (MTA-STS) | Hardenize Blog". www.hardenize.com. Archived from the original on April 25, 2019. Retrieved April 25, 2019.
- ^ "STARTTLS Everywhere". EFF. Archived from the original on August 9, 2019. Retrieved December 4, 2021.
- ^ v-mathavale (July 21, 2023). "How SMTP DNS-based Authentication of Named Entities (DANE) secures email communications". learn.microsoft.com. Retrieved March 5, 2024.
- ^ "Implementing Inbound SMTP DANE with DNSSEC for Exchange Online Mail Flow". techcommunity.microsoft.com. Retrieved March 5, 2024.
- ^ a b Cimpanu, Catalin. "Gmail becomes first major email provider to support MTA-STS and TLS Reporting". ZDNet. Archived from the original on April 29, 2019. Retrieved April 25, 2019.
- ^ "Message Non Compliant with RFC 5322". Archived from the original on January 17, 2023. Retrieved January 20, 2021.
- ^ "Message could not be delivered. Please ensure the message is RFC 5322 compliant". Archived from the original on January 28, 2021. Retrieved January 20, 2021.
- ^ "Why are the emails sent to Microsoft Account rejected for policy reasons?". Archived from the original on February 14, 2021. Retrieved January 20, 2021.
References
[edit]- Hughes, L (1998). Internet E-mail: Protocols, Standards and Implementation. Artech House Publishers. ISBN 978-0-89006-939-4.
- Hunt, C (2003). sendmail Cookbook. O'Reilly Media. ISBN 978-0-596-00471-2.
- Johnson, K (2000). Internet Email Protocols: A Developer's Guide. Addison-Wesley Professional. ISBN 978-0-201-43288-6.
- Loshin, P (1999). Essential Email Standards: RFCs and Protocols Made Practical. John Wiley & Sons. ISBN 978-0-471-34597-8.
- Rhoton, J (1999). Programmer's Guide to Internet Mail: SMTP, POP, IMAP, and LDAP. Elsevier. ISBN 978-1-55558-212-8.
- Wood, D (1999). Programming Internet Mail. O'Reilly. ISBN 978-1-56592-479-6.
Further reading
[edit]- RFC 1123 – Requirements for Internet Hosts—Application and Support (STD 3)
- RFC 1870 – SMTP Service Extension for Message Size Declaration (оbsoletes: RFC 1653)
- RFC 2505 – Anti-Spam Recommendations for SMTP MTAs (BCP 30)
- RFC 2821 – Simple Mail Transfer Protocol
- RFC 2920 – SMTP Service Extension for Command Pipelining (STD 60)
- RFC 3030 – SMTP Service Extensions for Transmission of Large and Binary MIME Messages
- RFC 3207 – SMTP Service Extension for Secure SMTP over Transport Layer Security (obsoletes RFC 2487)
- RFC 3461 – SMTP Service Extension for Delivery Status Notifications (obsoletes RFC 1891)
- RFC 3463 – Enhanced Status Codes for SMTP (obsoletes RFC 1893, updated by RFC 5248)
- RFC 3464 – An Extensible Message Format for Delivery Status Notifications (obsoletes RFC 1894)
- RFC 3798 – Message Disposition Notification (updates RFC 3461)
- RFC 3834 – Recommendations for Automatic Responses to Electronic Mail
- RFC 3974 – SMTP Operational Experience in Mixed IPv4/v6 Environments
- RFC 4952 – Overview and Framework for Internationalized Email (updated by RFC 5336)
- RFC 4954 – SMTP Service Extension for Authentication (obsoletes RFC 2554, updates RFC 3463, updated by RFC 5248)
- RFC 5068 – Email Submission Operations: Access and Accountability Requirements (BCP 134)
- RFC 5248 – A Registry for SMTP Enhanced Mail System Status Codes (BCP 138) (updates RFC 3463)
- RFC 5321 – The Simple Mail Transfer Protocol (obsoletes RFC 821 aka STD 10, RFC 974, RFC 1869, RFC 2821, updates RFC 1123)
- RFC 5322 – Internet Message Format (obsoletes RFC 822 aka STD 11, and RFC 2822)
- RFC 5504 – Downgrading Mechanism for Email Address Internationalization
- RFC 6409 – Message Submission for Mail (STD 72) (obsoletes RFC 4409, RFC 2476)
- RFC 6522 – The Multipart/Report Content Type for the Reporting of Mail System Administrative Messages (obsoletes RFC 3462, and in turn RFC 1892)
- RFC 6531 – SMTP Extension for Internationalized Email Addresses (updates RFC 2821, RFC 2822, RFC 4952, and RFC 5336)
- RFC 8314 – Cleartext Considered Obsolete: Use of Transport Layer Security (TLS) for Email Submission and Access
External links
[edit]Simple Mail Transfer Protocol
View on GrokipediaHistory
Early Precursors
The development of electronic mail predated the Simple Mail Transfer Protocol (SMTP), evolving from local systems on individual computers to rudimentary network-based exchanges on the ARPANET in the early 1970s.[11] Prior to networked capabilities, programs like MIT's MAILBOX in 1965 allowed users on the same time-sharing system to exchange messages stored in a shared file, but these were confined to single machines without inter-host communication.[12] In 1971, Ray Tomlinson at Bolt, Beranek and Newman (BBN) extended this concept across the ARPANET by modifying a file-copying utility called CPYNET, derived from the File Transfer Protocol (FTP), to send the first inter-computer messages between TENEX systems.[11] Tomlinson introduced the "@" symbol to delineate the user name from the host computer in addresses, enabling the format "user@host" that became foundational for email routing.[11] This innovation built on ARPANET's SNDMSG program, initially designed for local messaging on PDP-10 computers, allowing messages to be appended to remote mailboxes via network file transfers. Early ARPANET email relied on ad-hoc mail relays, where messages were forwarded between heterogeneous host systems using improvised scripts or manual intervention to bridge differing operating environments like TENEX and other implementations. For instance, FTP, formalized in RFC 114 in April 1971, was repurposed for "network mail" by transferring text files directly to recipients' mailbox directories on remote hosts, as later documented in RFC 469 (1973).[13] These relays formed primitive distribution lists and supported basic forwarding, but operated without a unified addressing or delivery mechanism. Such pre-SMTP systems suffered from significant limitations, including a lack of standardization that hindered interoperability across diverse ARPANET hosts, reliance on proprietary formats tied to specific software like SNDMSG, and vulnerability to network failures without robust error handling or queuing. Message formats varied, often embedding content in unstructured text files, which complicated parsing and multi-hop transmission as the network expanded beyond a handful of nodes. To address these issues, RFC 822 was published in 1982, establishing a standardized syntax for ARPA Internet text messages with structured headers for fields like From, To, and Subject, facilitating broader compatibility.[14] This format standard helped pave the way for SMTP as a dedicated transfer protocol to overcome the inefficiencies of FTP-based relays.[14]Standardization and Original RFC
The Simple Mail Transfer Protocol (SMTP) was formally standardized in August 1982 through RFC 821, authored by Jonathan B. Postel of the University of Southern California's Information Sciences Institute.[15] This document established SMTP as an Internet protocol for the reliable and efficient transfer of electronic mail messages between hosts, independent of specific transmission subsystems.[15] It defined a process-to-process communication standard, building briefly on earlier ARPANET mail systems to create a more structured framework for internetwork mail exchange.[15] RFC 821 introduced a client-server model, where a sender-SMTP process initiates a two-way transmission channel to a receiver-SMTP process on the destination host.[15] Key features included support for mail relaying, allowing intermediate hosts to forward messages across networks to reach final recipients, which facilitated scalability in diverse transport environments.[15] The protocol specified basic commands to orchestrate mail transfer, such as HELO for sender host identification, MAIL FROM to denote the message originator, RCPT TO to specify recipients, and DATA to transmit the mail content following command acknowledgments.[15] SMTP's operation in RFC 821 distinguished between the protocol's envelope—handled via commands like MAIL FROM and RCPT TO for routing and delivery—and the message content itself.[15] The content format was defined separately in the companion RFC 822, which standardized the syntax for ARPA Internet text messages, including headers like Date, Subject, To, Cc, and From, ensuring compatibility with SMTP's data transfer mechanism.[14] This separation allowed SMTP to focus on transport while RFC 822 governed the structured representation of mail data.[15]Evolution to Modern SMTP
Following the initial standardization of SMTP in RFC 821 in 1982, the protocol underwent significant evolution to address the expanding scale and complexities of the Internet. As email usage proliferated in the late 1980s and early 1990s, driven by the commercialization of the Internet and the growth of online communities, SMTP's original design—optimized for small-scale ARPANET exchanges—faced challenges in handling increased message volumes and diverse network environments. This period saw the recognition that rigid protocol constraints limited adaptability, prompting the development of mechanisms for extensibility without breaking backward compatibility.[16] A pivotal advancement came in 1995 with the publication of RFC 1869, which introduced Extended SMTP (ESMTP) as a framework for enhancing the protocol. Authored by John Klensin, Ned Freed, Marshall T. Rose, Einar A. Stefferud, and Dave Crocker, this specification defined a structured approach to adding optional features through server-declared capabilities, registered with the Internet Assigned Numbers Authority (IANA). Central to ESMTP was the EHLO command, which replaced the basic HELO greeting to initiate sessions; upon receiving EHLO, servers respond with a 250 status code followed by a list of supported extensions, enabling clients to negotiate advanced functionalities dynamically. This design preserved the core SMTP session flow while allowing incremental improvements, ensuring that legacy systems using HELO continued to interoperate seamlessly. ESMTP's emphasis on simplicity and scrutiny of extension overheads addressed the need for a ubiquitous mail relay protocol amid rising Internet traffic.[17] By the early 2000s, the explosive growth of email—coupled with the surge in unsolicited bulk messages (spam)—further necessitated refinements to SMTP's foundational elements. Spam emerged as a major issue in the mid-1990s, with large-scale campaigns appearing on USENET and email lists by 1994, and by 2003, spam volume surpassed legitimate email traffic for the first time. This proliferation exploited SMTP's lack of built-in sender authentication, leading to widespread open relay abuse and hijacking as early as 1997. In response, the Internet Engineering Task Force (IETF) updated the core specification in RFC 2821, published in April 2001 by John C. Klensin. This document obsoleted RFC 821 and RFC 974, while updating RFC 1123, consolidating prior clarifications and incorporating the ESMTP extension model more fully into the standard. Key changes included deprecating unused features like source routing and the TURN command, mandating four-digit date formats, and enhancing error handling to better support larger-scale deployments, all while maintaining compatibility with the original commands from RFC 821 as the protocol's foundation. These revisions reflected adaptations to a maturing Internet infrastructure, where email had become a primary communication medium handling billions of messages annually.[16][18][19] The current core specification, RFC 5321, published in October 2008 and also authored by John C. Klensin, further refined SMTP by obsoleting RFC 2821 and providing updated guidance for modern environments. As a Draft Standard on the Internet Standards Track, it clarified operational details, improved loop detection, and aligned the protocol with IPv6 support and enhanced security practices, responding to ongoing challenges like spam mitigation through extensible mechanisms. This update emphasized SMTP's role not only in mail transfer but also in submission for split-user-agent systems, accommodating mobile and distributed users. Since 2008, the IETF has continued iterative enhancements via working groups, such as updates in RFC 7504 (2015) for authenticated SMTP submission and ongoing efforts in the EMAILCORE group to ensure robustness against evolving threats and network scales. These developments have solidified SMTP's resilience, enabling it to transport trillions of emails yearly while incorporating defenses against abuse.[20][21]Protocol Fundamentals
Mail Processing Model
The Simple Mail Transfer Protocol (SMTP) operates on a store-and-forward model, where electronic mail messages are relayed across networks through intermediate systems until they reach their final destination. In this model, messages are submitted by originating systems, relayed by intermediate servers, and ultimately delivered to recipient mailboxes. This approach allows for reliable transmission even across heterogeneous networks, as each relay point temporarily stores the message before forwarding it to the next hop, determined via Domain Name System (DNS) mail exchanger (MX) records.[22] Central to this process are distinct roles played by various agents. Mail Transfer Agents (MTAs) are responsible for the core transport and relaying of messages between servers, accepting incoming mail and forwarding it without altering the content, except for adding trace headers. Mail Submission Agents (MSAs) handle the initial acceptance of messages from Mail User Agents (MUAs), such as email clients, validating and preparing them for entry into the SMTP network before passing them to MTAs.[23] Mail Delivery Agents (MDAs), in contrast, manage the final handover of messages to local mailboxes or MUAs upon receipt by the destination MTA, as described for delivery systems in the SMTP specification.[24] SMTP distinguishes between the message envelope and the message content to facilitate efficient routing. The envelope consists of sender and recipient addresses (specified via commands like MAIL FROM and RCPT TO), which SMTP uses exclusively for determining the path and ensuring delivery accountability, without inspecting the content. The actual message content, including headers and body, is transmitted opaquely as a block and is not involved in routing decisions; this separation enables SMTP to focus solely on transport while leaving content handling to higher-level protocols. Unlike retrieval protocols such as POP3 or IMAP, which enable end-user access to stored mail, SMTP is dedicated to the transfer phase.[25][26]Core SMTP Session Flow
The core SMTP session begins with the client initiating a TCP connection to the SMTP server, typically on port 25, after resolving the destination domain using DNS MX records to identify the appropriate mail exchanger host.RFC 5321, Section 5.1 The MX record lookup involves querying the domain for mail exchanger records ordered by preference value, starting with the lowest; if no MX records exist, the domain itself is treated as an implicit MX with preference 0, followed by an A or AAAA record resolution to obtain the IP address.RFC 5321, Section 5.1 Upon successful connection, the server immediately sends a 220 greeting response containing its domain name and a timestamp, signaling readiness and marking the start of the session.RFC 5321, Section 3.1 Following the greeting, the client enters the transaction phase by sending an EHLO (Extended HELO) or HELO command with its domain name to identify itself; the server responds with a 250 OK code, optionally listing supported extensions in the case of EHLO.RFC 5321, Section 4.1.1.1 The client then issues the MAIL FROM command specifying the sender's reverse-path address, to which the server replies with 250 if accepted, initiating the mail transaction envelope that encapsulates the sender and eventual recipients.RFC 5321, Section 4.1.1.2 Next, one or more RCPT TO commands define the recipient addresses, with the server responding 250 for acceptance or an error code if rejected, such as 550 for a permanent failure like an invalid address.RFC 5321, Section 4.1.1.3 Once recipients are confirmed, the client sends the DATA command; the server acknowledges with a 354 response prompting the message content, which the client transmits line-by-line, terminating with a single period on a line (.Basic Commands and Responses
The Simple Mail Transfer Protocol (SMTP) relies on a set of core commands issued by the client to the server to initiate and manage mail transactions, along with standardized response codes from the server to indicate the status of each operation. These commands form the foundation of base SMTP communication, ensuring reliable transfer of electronic mail between hosts. All commands are transmitted as lines of US-ASCII text, limited to 7-bit characters (with the high-order bit set to zero), and each command line must not exceed 512 octets, including the carriage return and line feed (CRLF) terminators.[27][28] The primary commands include those for session initiation, transaction setup, message delivery, and session termination. The HELO command identifies the client host to the server at the start of a session, using the syntaxHELO SP domain CRLF, where domain is the fully qualified domain name of the sending host; it has no effect on transaction buffers and can be issued at any time.[29] The MAIL FROM command begins a new mail transaction by specifying the sender's reverse path, with syntax MAIL FROM: SP <reverse-path> CRLF, where <reverse-path> indicates the return address for error notifications; this command must follow a successful HELO and clears any previous transaction state.[30] Following that, the RCPT TO command adds one or more recipients to the transaction, using RCPT TO: SP <forward-path> CRLF, where <forward-path> specifies the delivery path for the recipient; multiple RCPT TO commands can be used for multi-recipient messages, but each requires a successful response before proceeding.[31]
To transmit the actual message content, the DATA command is employed after successful MAIL FROM and RCPT TO sequences, with syntax DATA CRLF; the server responds affirmatively, after which the client sends the message header and body lines, each up to 1000 octets long, terminated by a single line containing only a period (.) preceded and followed by CRLF (<CRLF>.<CRLF>).[32][28] For session management, the RSET command resets the transaction state without affecting the overall connection, using RSET CRLF, which aborts any ongoing mail transfer and clears recipient buffers.[33] The NOOP command performs no action but confirms the connection's viability, with syntax NOOP [SP string] CRLF, often used for keep-alives.[34] Finally, the QUIT command terminates the SMTP session gracefully, using QUIT CRLF, after which the server closes the transmission channel.[35] These commands collectively support the sequential flow of an SMTP session, from greeting to mail relay and logout.
Server responses to these commands are three-digit numeric codes prefixed to a human-readable explanation, categorized by the first digit to denote outcome types. A 2xx code signifies successful completion, such as 250 OK following a valid HELO or MAIL FROM, indicating the action was accepted and the client may proceed.[36] A 3xx code requests further action from the client, exemplified by 354 Start mail input; end with | Command | Syntax | Purpose | Typical Response |
|---|---|---|---|
| HELO | HELO SP domain CRLF | Client identification | 250 domain OK |
| MAIL FROM | MAIL FROM: SP <reverse-path> CRLF | Start transaction, specify sender | 250 2.1.0 |
| RCPT TO | RCPT TO: SP <forward-path> CRLF | Add recipient | 250 2.1.5 |
| DATA | DATA CRLF (followed by message ended by <CRLF>.<CRLF>) | Transmit message | 354 Start mail input; 250 2.0.0 OK |
| RSET | RSET CRLF | Reset transaction | 250 2.0.0 OK |
| NOOP | NOOP [SP string] CRLF | No operation, connection check | 250 2.0.0 OK |
| QUIT | QUIT CRLF | End session | 221 2.0.0 Bye |
Server and Network Aspects
Outgoing Mail Servers
Outgoing mail servers in the Simple Mail Transfer Protocol (SMTP) ecosystem primarily consist of Mail Transfer Agents (MTAs) and Message Submission Agents (MSAs), which handle the transmission of email from originating sources to destination systems.[42][43] An MTA is a program responsible for receiving and relaying mail messages between servers, acting as both an SMTP client to send mail and a server to accept it from other MTAs or MSAs.[42] In contrast, an MSA serves as a submission server that accepts messages directly from Mail User Agents (MUAs), such as email clients, and either delivers them locally or relays them to an MTA for further transport.[43] These servers are typically deployed at network edges, such as by Internet Service Providers (ISPs), where MSAs interface with end-user devices and MTAs manage inter-domain relaying to ensure reliable propagation across the internet.[42][43] Configuration of outgoing mail servers involves setting up listening interfaces on designated ports, implementing message queuing for delivery retries, and leveraging Domain Name System (DNS) mechanisms for routing decisions. MTAs and MSAs listen for incoming connections, with MTAs commonly using port 25 for relay operations as specified in SMTP standards.[42] MSAs, however, utilize port 587 for message submission via Extended SMTP (ESMTP), enabling secure and authenticated handoffs from user agents.[43] Queue management is a core feature, particularly for MTAs, which store undelivered messages and implement retry schedules—typically with initial intervals of at least 30 minutes and persistence up to 4-5 days—to handle temporary failures like network issues or recipient unavailability.[42] For routing, these servers integrate with DNS by querying Mail Exchanger (MX) records to identify the next-hop destination for a given domain, prioritizing lower-cost paths based on preference values in the records.[42] The distinction between submission and relay servers underscores their specialized roles in outgoing mail handling. Submission servers (MSAs on port 587) are designed for initial message intake from authenticated users, often allowing modifications like adding missing headers (e.g., Date or Message-ID) to ensure compliance, and they reject malformed submissions immediately with error codes.[43] Relay servers (MTAs on port 25), by comparison, facilitate peer-to-peer transfers between mail systems without altering message content, focusing on efficient forwarding while enforcing stricter relay policies to prevent abuse.[42] This separation enhances security and reliability, as submission ports support user authentication and are isolated from open relaying risks inherent in traditional MTA operations.[43][42]Ports and Connectivity
The Simple Mail Transfer Protocol (SMTP) relies on specific TCP ports for establishing connections between mail transfer agents (MTAs) and for message submission from clients. The primary port for server-to-server email relay is TCP port 25, which enables the exchange of messages across the Internet as defined in the original SMTP specification.[15] This port supports unauthenticated transfers between trusted MTAs but is frequently subject to restrictions due to its association with spam propagation. For secure message submission, typically from mail user agents (MUAs) to MTAs, TCP port 587 is designated, where authentication mechanisms are mandatory to authorize senders and prevent open relaying.[23] TCP port 465 is designated for message submission using SMTP over implicit TLS, recommended by RFC 8314 as the long-term preferred option for secure connections, in addition to port 587 which supports STARTTLS as a transitional method.[44] Some email service providers utilize TCP port 2525 as a non-standard alternative, particularly in environments where traditional ports are unavailable.[45] SMTP connectivity is fundamentally TCP-based, with the client initiating a three-way handshake to the server's listening port to open a reliable, ordered stream for command-response exchanges.[1] Upon successful connection, the server issues a 220 "Service ready" greeting, after which the client sends an EHLO or HELO command to begin the session; failure to receive this greeting prompts the client to terminate the connection. To manage unreliable networks, RFC 5321 imposes strict timeouts: the initial connection and greeting response must complete within 5 minutes, while commands like MAIL FROM and RCPT TO each have a 5-minute limit, DATA initiation allows 2 minutes, individual data blocks 3 minutes, and DATA termination 10 minutes.[46] The server also enforces a 5-minute idle timeout between commands to avoid resource exhaustion. These parameters ensure efficient resource use and prevent indefinite hangs, with clients recommended to implement exponential backoff for retries on transient failures. Firewall and Network Address Translation (NAT) configurations present significant challenges for SMTP traffic, often requiring careful policy design to balance security and functionality. Many Internet Service Providers (ISPs), such as AT&T for its residential customers, block outbound TCP port 25 connections from residential or dynamic IP addresses to external SMTP servers to curb spam from botnets, virus emails, unauthorized relays, and abuse from compromised devices. This practice, commonly referred to as Outbound Port 25 Blocking (OP25B) and widely adopted by many ISPs since the mid-2000s (particularly in Japan where the term originated), is rooted in anti-abuse recommendations.[47][48][49] This requires customers to use authenticated SMTP submission on alternative ports such as 587 or 465, often via the ISP's own servers (e.g., outbound.att.net for AT&T) or third-party providers like Gmail that support authenticated submission. Inbound restrictions on port 25 are common to protect against external attacks, directing legitimate traffic through authenticated submission ports like 587. In NAT environments, SMTP's inclusion of IP addresses in headers (e.g., "Received:" lines) can expose private addresses, complicating traceability and routing; application-layer gateways (ALGs) are thus advised to rewrite these fields dynamically while maintaining message integrity.[50] Such measures ensure SMTP remains viable in traversed networks without compromising end-to-end delivery. In outgoing mail server setups, these ports and considerations enable seamless integration with broader email infrastructure.Access Restrictions and Authentication
Access to SMTP servers is often restricted based on the client's IP address to prevent unauthorized use and reduce spam. IP allowlisting permits connections only from predefined trusted networks, typically configured in mail transfer agents (MTAs) like Postfix using themynetworks parameter or smtpd_client_restrictions to explicitly allow specific IP ranges or hosts before applying broader rejection policies.[51] Geoblocking extends this by denying connections from IP addresses associated with certain countries, leveraging geolocation databases integrated into access controls, as implemented in systems like Cisco Email Security Appliance where sender groups can reject mail based on geographic origin.[52] Realtime Blackhole Lists (RBLs), also known as DNSBLs, provide a collaborative mechanism where MTAs query DNS-based lists of known abusive IP addresses; for example, Postfix uses the reject_rbl_client directive in smtpd_recipient_restrictions to block clients listed in services like Spamhaus Zen, enhancing protection against spam sources.[51]
Starting in 2024, major email providers including Google, Yahoo, and Microsoft have implemented requirements for bulk email senders (over 5,000 emails per day) to authenticate via Sender Policy Framework (SPF), DomainKeys Identified Mail (DKIM), and Domain-based Message Authentication, Reporting, and Conformance (DMARC) to prevent spoofing and improve deliverability; non-compliance may result in rejection or spam filtering as of May 2025.[53]
Client authentication in SMTP is facilitated by the SMTP Service Extension for Authentication (SMTP-AUTH), defined in RFC 4954, which allows clients to negotiate and perform authentication using Simple Authentication and Security Layer (SASL) mechanisms during the SMTP session.[54] Common mechanisms include PLAIN, which transmits username and password in cleartext and must be used over a secure channel like TLS (per RFC 4616), and CRAM-MD5, a challenge-response method using HMAC-MD5 for added security without sending passwords directly (per RFC 2195).[55] The LOGIN mechanism, a non-standard plaintext variant similar to PLAIN, is widely supported for compatibility with clients like Microsoft Outlook but shares the same security requirements for encryption. As of November 2025, major providers such as Microsoft are deprecating Basic Authentication mechanisms like PLAIN and LOGIN in favor of more secure alternatives such as OAuth 2.0.[56] SMTP-AUTH is advertised via the AUTH EHLO keyword, and the exchange occurs after the initial SMTP greeting but before message transfer, with servers rejecting unauthenticated relays to external domains.[54]
To further mitigate abuse such as denial-of-service attacks or spam floods, SMTP servers implement rate limiting, which caps the number of connections, messages, or recipients per client IP or session within a time window; for instance, Microsoft Exchange enforces limits like 1200 messages per minute per source to ensure fair usage and prevent overload.[57] Greylisting complements this by temporarily rejecting mail from unknown senders with a 4xx SMTP error code, exploiting the fact that legitimate MTAs retry delivery per RFC 5321 while many spam bots do not, typically using a triplet of sender IP, envelope sender, and recipient for tracking (as outlined in RFC 6647).[58] These techniques are often combined, with greylisting applied early in the SMTP dialog and exceptions for authenticated or whitelisted clients to minimize disruption.[58]
Operational Mechanics
SMTP Transport Example
A typical SMTP transport example illustrates the protocol's client-server dialogue for transferring an email message from a sending host to a receiving host. This exchange follows the core sequence defined in the Simple Mail Transfer Protocol, beginning with connection establishment and greeting, followed by optional authentication, envelope specification, recipient validation, message data transmission, and session termination.[1] The example below depicts a scenario where a client atclient.example.com sends mail to multiple recipients at mail.example.com, incorporating Extended SMTP (ESMTP) via the EHLO command and optional authentication using the AUTH extension for PLAIN mechanism over TLS (though TLS negotiation is omitted here for brevity; in practice, STARTTLS would precede AUTH).[1][54]
The dialogue uses the following conventions: lines prefixed with S: represent server responses, C: represent client commands, and annotations explain each step, including standard three-digit response codes (e.g., 220 for service ready, 250 for success, 354 for data input start, 550 for permanent failure). Response codes are structured as a digit indicating the status class (2xx success, 3xx continue, 4xx transient failure, 5xx permanent failure), followed by a second digit for the subject, and a third for details.[40]
S: 220 mail.example.com ESMTP service ready
# The server announces its readiness upon TCP connection on port 25 (or 587 for submission), providing the domain and ESMTP support. This initiates the session.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.3.2)
C: EHLO client.example.com
# The client identifies itself with its domain using EHLO to request ESMTP capabilities, such as supported extensions (e.g., 8BITMIME for [binary data](/page/Binary_data)). If ESMTP is unavailable, HELO could be used instead.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.1)
S: 250-mail.example.com
250-AUTH PLAIN LOGIN
250-8BITMIME
250-SIZE 51200000
250 OK
# The server lists supported extensions (AUTH for authentication mechanisms like [PLAIN](/page/The_Plain), 8BITMIME for 8-bit data, [SIZE](/page/Size) for maximum message size) and confirms the greeting. The client may now use these if needed.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.4)[](https://datatracker.ietf.org/doc/html/rfc4954#section-4)
C: AUTH [PLAIN](/page/The_Plain) AGVhZEBleGFtcGxlLmNvbQB3b3Jk
# Optional: The client authenticates using the [PLAIN](/page/The_Plain) mechanism, sending base64-encoded credentials (authorization ID, authentication ID, password). This step is required for authorized submission (e.g., on port 587) to prevent open relay abuse but may be skipped for trusted inter-server transfers. If authentication fails, the server responds with 535.[](https://datatracker.ietf.org/doc/html/rfc4954#section-6)
S: 235 2.7.0 Authentication successful
# The server confirms successful [authentication](/page/Authentication), allowing the transaction to proceed. Without AUTH, the client could continue directly if permitted.[](https://datatracker.ietf.org/doc/html/rfc4954#section-6)
C: MAIL FROM:<[email protected]> SIZE=1024
# The client specifies the sender's [envelope](/page/Envelope) [address](/page/Address) (reverse path for bounces) and optional [message](/page/Message) [size](/page/Size). The SIZE parameter leverages the ESMTP extension announced earlier. If invalid, the server might reply 553 or 552 (quota exceeded).[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.2)
S: 250 2.1.0 Sender address accepted
# The server accepts the sender, validating it against policies (e.g., no invalid domains). This starts the mail transaction.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.2)
C: RCPT TO:<[email protected]>
# The client specifies the first recipient's envelope address. Multiple RCPT commands can follow for batch delivery in one session, improving efficiency over separate connections.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.3)
S: 250 2.1.5 Recipient OK
# The server accepts the recipient after local validation (e.g., mailbox existence). For a single-recipient message, only one RCPT is used; multiples allow one message to multiple destinations.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.3)
C: RCPT TO:<[email protected]>
# Second recipient attempt, demonstrating multi-recipient variation.
S: 550 5.1.1 Recipient2: User unknown
# The server rejects the recipient permanently (e.g., invalid mailbox), using 550 to indicate failure without halting the transaction—other recipients can still succeed. The client might retry later or notify the sender. In contrast, a transient error like [450](/page/450) (temporary failure) would allow retry.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.2.3)
C: RCPT TO:<[email protected]>
# Third recipient, continuing despite the prior rejection.
S: 250 2.1.5 Recipient OK
# Accepted, showing that rejections are per-recipient; the message proceeds to valid ones (here, recipient1 and recipient3).[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.3)
C: [DATA](/page/Data)
# The client requests to send the message content (headers and body per RFC 5322). No more RCPT or MAIL commands are allowed until the current transaction ends. If recipients were rejected entirely, the server might reply 503.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.4)
S: 354 Start mail input; end with <CRLF>.<CRLF>
# The server invites data input, specifying the line-oriented format ending with a single dot (.) on its own line. The client has a timeout (typically 5-10 minutes) to complete transmission.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.4)
C: From: sender@client.[example.com](/page/Example.com)
To: recipient1@[mail](/page/Mail).example.com, recipient3@[mail](/page/Mail).example.com
Subject: Test Message
This is the body of the [email](/page/Email).
.
# The client transmits the full [message](/page/Message): RFC 5322-compliant headers (e.g., From, To for display names; note envelope addresses differ), followed by the body, ended by the dot. The rejected recipient2 is omitted from headers. [Binary data](/page/Binary_data) would use 8BITMIME if supported. If transmission fails (e.g., size limit), the server replies 552.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.4)
S: 250 2.6.0 [Message](/page/Message) accepted for delivery
# The server confirms receipt and queues the [message](/page/Message) for the accepted recipients, ending the transaction. Errors here (e.g., [451](/page/451) for [resource](/page/Resource) issues) are transient.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.4)
C: QUIT
# The client requests session closure, optional but recommended to free [resources](/page/Resource). Multiple transactions can occur in one session before QUIT.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.5)
S: 221 2.0.0 mail.example.com closing connection
# The server closes the TCP connection after any final processing. If the client disconnects abruptly, the server treats it as an implicit QUIT.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.5)
S: 220 mail.example.com ESMTP service ready
# The server announces its readiness upon TCP connection on port 25 (or 587 for submission), providing the domain and ESMTP support. This initiates the session.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.3.2)
C: EHLO client.example.com
# The client identifies itself with its domain using EHLO to request ESMTP capabilities, such as supported extensions (e.g., 8BITMIME for [binary data](/page/Binary_data)). If ESMTP is unavailable, HELO could be used instead.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.1)
S: 250-mail.example.com
250-AUTH PLAIN LOGIN
250-8BITMIME
250-SIZE 51200000
250 OK
# The server lists supported extensions (AUTH for authentication mechanisms like [PLAIN](/page/The_Plain), 8BITMIME for 8-bit data, [SIZE](/page/Size) for maximum message size) and confirms the greeting. The client may now use these if needed.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.4)[](https://datatracker.ietf.org/doc/html/rfc4954#section-4)
C: AUTH [PLAIN](/page/The_Plain) AGVhZEBleGFtcGxlLmNvbQB3b3Jk
# Optional: The client authenticates using the [PLAIN](/page/The_Plain) mechanism, sending base64-encoded credentials (authorization ID, authentication ID, password). This step is required for authorized submission (e.g., on port 587) to prevent open relay abuse but may be skipped for trusted inter-server transfers. If authentication fails, the server responds with 535.[](https://datatracker.ietf.org/doc/html/rfc4954#section-6)
S: 235 2.7.0 Authentication successful
# The server confirms successful [authentication](/page/Authentication), allowing the transaction to proceed. Without AUTH, the client could continue directly if permitted.[](https://datatracker.ietf.org/doc/html/rfc4954#section-6)
C: MAIL FROM:<[email protected]> SIZE=1024
# The client specifies the sender's [envelope](/page/Envelope) [address](/page/Address) (reverse path for bounces) and optional [message](/page/Message) [size](/page/Size). The SIZE parameter leverages the ESMTP extension announced earlier. If invalid, the server might reply 553 or 552 (quota exceeded).[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.2)
S: 250 2.1.0 Sender address accepted
# The server accepts the sender, validating it against policies (e.g., no invalid domains). This starts the mail transaction.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.2)
C: RCPT TO:<[email protected]>
# The client specifies the first recipient's envelope address. Multiple RCPT commands can follow for batch delivery in one session, improving efficiency over separate connections.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.3)
S: 250 2.1.5 Recipient OK
# The server accepts the recipient after local validation (e.g., mailbox existence). For a single-recipient message, only one RCPT is used; multiples allow one message to multiple destinations.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.3)
C: RCPT TO:<[email protected]>
# Second recipient attempt, demonstrating multi-recipient variation.
S: 550 5.1.1 Recipient2: User unknown
# The server rejects the recipient permanently (e.g., invalid mailbox), using 550 to indicate failure without halting the transaction—other recipients can still succeed. The client might retry later or notify the sender. In contrast, a transient error like [450](/page/450) (temporary failure) would allow retry.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.2.3)
C: RCPT TO:<[email protected]>
# Third recipient, continuing despite the prior rejection.
S: 250 2.1.5 Recipient OK
# Accepted, showing that rejections are per-recipient; the message proceeds to valid ones (here, recipient1 and recipient3).[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.3)
C: [DATA](/page/Data)
# The client requests to send the message content (headers and body per RFC 5322). No more RCPT or MAIL commands are allowed until the current transaction ends. If recipients were rejected entirely, the server might reply 503.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.4)
S: 354 Start mail input; end with <CRLF>.<CRLF>
# The server invites data input, specifying the line-oriented format ending with a single dot (.) on its own line. The client has a timeout (typically 5-10 minutes) to complete transmission.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.4)
C: From: sender@client.[example.com](/page/Example.com)
To: recipient1@[mail](/page/Mail).example.com, recipient3@[mail](/page/Mail).example.com
Subject: Test Message
This is the body of the [email](/page/Email).
.
# The client transmits the full [message](/page/Message): RFC 5322-compliant headers (e.g., From, To for display names; note envelope addresses differ), followed by the body, ended by the dot. The rejected recipient2 is omitted from headers. [Binary data](/page/Binary_data) would use 8BITMIME if supported. If transmission fails (e.g., size limit), the server replies 552.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.4)
S: 250 2.6.0 [Message](/page/Message) accepted for delivery
# The server confirms receipt and queues the [message](/page/Message) for the accepted recipients, ending the transaction. Errors here (e.g., [451](/page/451) for [resource](/page/Resource) issues) are transient.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.4)
C: QUIT
# The client requests session closure, optional but recommended to free [resources](/page/Resource). Multiple transactions can occur in one session before QUIT.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.5)
S: 221 2.0.0 mail.example.com closing connection
# The server closes the TCP connection after any final processing. If the client disconnects abruptly, the server treats it as an implicit QUIT.[](https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.5)
Message Queue Management
SMTP servers manage message queues to handle the temporary storage and processing of emails that cannot be delivered immediately, ensuring reliable transport despite transient failures. Queues typically consist of distinct structures such as the incoming queue for newly received messages awaiting initial processing, the active queue for messages currently undergoing delivery attempts, and the deferred queue for messages that have encountered temporary errors and require retries. These structures allow the server to organize mail flow efficiently, with messages moving from incoming to active upon resource availability, and to deferred on failure before reattempting. Storage methods vary by implementation; for instance, widely-used mail transfer agents (MTAs) like Postfix employ file-based storage on disk for incoming and deferred queues, while others like Microsoft Exchange utilize a database for all queue types to facilitate querying and management.[61][62] Retry algorithms are essential for queue management, employing strategies to reattempt delivery without overwhelming the network or recipient servers. Per RFC 5321, after a temporary failure (indicated by a 4xx SMTP response code), the server must queue the message and retry with intervals of at least 30 minutes following the initial attempt, continuing for a total period of 4 to 5 days before deeming it undeliverable. A recommended schedule includes two attempts within the first hour, followed by retries every 2 to 3 hours, often incorporating exponential backoff to progressively increase delays—starting from 5-10 minutes initially and extending to hours or days—to mitigate congestion. This approach balances persistence with resource efficiency, as outlined in the protocol specification.[63] For messages that remain undeliverable after exhaustive retries, servers generate bounce messages to notify the originator of the failure. These notifications, known as Delivery Status Notifications (DSNs), are standardized in RFC 3461 as an SMTP extension, allowing specification of reporting conditions (e.g., failure or delay) via parameters in the MAIL and RCPT commands. Upon final failure (e.g., a 5xx response or timeout), the server creates a DSN report in MIME multipart/report format, including details like the reporting MTA, action taken, status code, and optionally the original message content or headers, sent to the envelope return path using a null reverse-path to prevent loops. This mechanism ensures transparency in delivery outcomes while adhering to privacy and loop-prevention guidelines.[64]Delivery Mechanisms
In SMTP systems, final delivery often occurs locally after the message has been relayed to the destination server, where a Mail Delivery Agent (MDA) processes the email for storage in user mailboxes or further handling. MDAs such as procmail receive messages from the Mail Transfer Agent (MTA) and apply filters, sort content, or deliver directly to spool files or Maildir formats, ensuring efficient local placement without network transmission.[65] Procmail, for instance, filters incoming mail based on headers, body content, or keywords before final delivery, supporting conditional rules for forwarding or archiving. To facilitate local delivery without the queuing semantics of standard SMTP, the Local Mail Transfer Protocol (LMTP), defined in RFC 2033, serves as a variant optimized for intra-system transfers. LMTP employs ESMTP syntax but modifies the session flow: it uses LHLO for greeting, returns per-recipient responses after the DATA command terminator, and avoids server-side queuing, allowing the client (typically the MTA) to manage retries for individual failures.[66] This makes LMTP ideal for delivering messages from an MTA to multiple local MDAs or storage backends on the same host, such as in scenarios involving shared mailboxes or gateways, where immediate status feedback per recipient enhances efficiency over SMTP's store-and-forward model.[66] For remote delivery, SMTP relies on relay servers that forward messages across networks using MX records from the Domain Name System (DNS) to determine the next hop, with preferences guiding the order of attempts.[60] In cases of intermittent connectivity or dynamic IP addresses, such as with mobile or dial-up systems, the On-Demand Mail Relay (ODMR) protocol provides a pull-based alternative, as specified in RFC 2645. ODMR operates as a restricted SMTP profile on port 366, beginning with standard EHLO and AUTH commands for client authentication via SASL mechanisms like CRAM-MD5, followed by the ATRN command to request queued mail for specific domains, which reverses roles and initiates transfer.[67] This enables recipients to retrieve accumulated mail on demand, with sessions supporting timeouts of at least 10 minutes to accommodate variable connection times.[67] SMTP routing incorporates mechanisms for aliases, mailing lists, and virtual domains to expand or redirect addresses during envelope processing, ensuring accurate final delivery. Aliases replace a pseudo-mailbox (e.g., a local name) with one or more real recipient addresses in the RCPT stage, preserving the original message body while updating the envelope for delivery.[68] For mailing lists, the process similarly expands the recipient list but modifies the return path to a list administrator's address, allowing notifications for undeliverable messages to route appropriately without exposing full membership.[69] Virtual domains are handled through DNS MX records, which map domain names to hosting servers; multiple records with preference values enable load balancing or failover, treating the domain as a logical entity independent of physical hosts.[70] CNAME records further support aliasing at the domain level, recursively resolving to canonical names before MX queries.[70] Queuing precedes these mechanisms as an interim step, buffering messages for routing attempts.[71]Extensions and Enhancements
ESMTP Discovery Mechanism
The Extended Simple Mail Transfer Protocol (ESMTP) discovery mechanism enables clients to identify and negotiate optional extensions supported by an SMTP server, enhancing the basic protocol's capabilities without breaking compatibility. This process begins when an SMTP client issues the EHLO command, which stands for "Extended HELO," followed by the client's fully qualified domain name or an address literal, such asEHLO [example.com](/page/Example.com).[29] Unlike the basic HELO command, which serves as a non-extended baseline for session initialization, EHLO prompts the server to advertise its supported extensions in the response.[29]
Upon receiving the EHLO command, a compliant ESMTP server must respond with a multi-line 250 status code, where the initial lines begin with "250-" followed by keywords indicating supported extensions, and the final line starts with "250 " to signify completion.[29] Each extension keyword may be accompanied by parameters that specify further details or options, such as 250-AUTH [PLAIN](/page/The_Plain) [LOGIN](/page/Login) to indicate support for the AUTH extension with PLAIN and LOGIN mechanisms, or 250-8BIT[MIME](/page/MIME) to signal handling of 8-bit MIME content.[29] Servers are required to advertise all non-private extensions in this manner, ensuring that only registered extensions—those defined in IETF Standards-Track or Experimental documents and listed with IANA—are included, prefixed without an "X-" unless experimental.[72] The order of these parameters and extensions in the response lines is not mandated by the specification, allowing servers flexibility in presentation while maintaining parseability.[29]
If a server does not support ESMTP and rejects the EHLO command—typically with a 502 response—the client must fall back to the basic HELO command to initiate a standard SMTP session, as all servers are required to support HELO for backward compatibility.[73] Clients encountering unknown or unrecognized extensions in the 250 response should ignore them and proceed only with those they understand and require, preventing errors from unsupported features.[29] This negotiation ensures robust interoperability, as servers must not offer capabilities they cannot fulfill and clients must not attempt parameters beyond those explicitly advertised.[31]
Data Transfer and Format Extensions
The Simple Mail Transfer Protocol (SMTP) originally supported only 7-bit ASCII text, necessitating encodings like base64 or quoted-printable for non-ASCII content, which increased message size and processing overhead. To address these limitations, several extensions enhance data transfer and format capabilities, allowing more efficient handling of binary, 8-bit, and large messages while preserving data integrity. These extensions are advertised by servers in response to the EHLO command, enabling clients to negotiate their use during the SMTP session.[74][75][76] The 8BITMIME extension, specified in RFC 6152, permits the direct transmission of 8-bit MIME messages containing octets beyond the US-ASCII range (hex 00-7F), supporting arbitrary octet-aligned content without mandatory 7-bit conversion.[74] Clients indicate support by including the BODY parameter with the value "8BITMIME" in the extended MAIL command after the server advertises the "8BITMIME" keyword in its EHLO response, which has no parameters.[74] Receiving servers must preserve all bits in the octets during relay, including the 8th bit, and adhere to the maximum line length of 1000 octets (including the <CR><LF>), as specified in the base SMTP protocol.[74] Clients are required to avoid sending 8-bit content to non-supporting servers and may fall back to 7-bit MIME encoding if necessary, but this extension does not accommodate binary content-transfer-encodings like those in MIME.[74] For handling large and binary MIME messages more efficiently, the BINARYMIME extension, outlined in RFC 3030, introduces chunked binary transfer to eliminate the overhead of textual encodings.[75] It relies on the companion CHUNKING extension, advertised via the "CHUNKING" EHLO keyword, and is signaled by the "BINARYMIME" keyword, which requires CHUNKING for operation.[75] Instead of the traditional DATA command, clients use the BDAT command to send data in specified chunks: each BDAT includes a required chunk-size argument in octets (e.g., BDAT 100000) followed immediately by the data, with the receiver acknowledging exactly that amount via a 250 response; the final chunk is marked with the optional "LAST" parameter (e.g., BDAT 0 LAST).[75] The MAIL command may include a BODY=BINARYMIME parameter, and receivers must preserve all octet bits while enforcing canonicalInternationalization and Relay Extensions
The Email Address Internationalization (EAI) framework, defined in RFC 6530, provides a comprehensive set of specifications to enable the use of internationalized email addresses containing non-ASCII characters, addressing the limitations of traditional ASCII-only email systems.[77] This framework replaces earlier efforts like RFC 4952 and relies on UTF-8 encoding to support Unicode characters in email addresses, headers, and related protocols.[77] Key components include the SMTPUTF8 extension for message transfer, UTF-8-based header formatting, and support for internationalized Delivery Status Notifications (DSNs), ensuring end-to-end handling of non-ASCII content without intermediate downgrading.[77] Implementation requires systems to support the 8BITMIME extension (RFC 6152) for binary data transmission, and domain names must conform to Internationalizing Domain Names in Applications (IDNA) standards (RFC 5890) using A-labels or U-labels.[77] The SMTPUTF8 extension, specified in RFC 6531, extends the Simple Mail Transfer Protocol (SMTP) to permit UTF-8 strings in envelope addresses, headers, and the message body, facilitating global email interoperability.[78] Servers advertise support for this extension by including the "SMTPUTF8" keyword in their EHLO response without parameters, signaling to clients that non-ASCII content can be used.[78] In the MAIL and RCPT commands, internationalized addresses follow an extendedATRN [SP domain *("," domain)].[67] Authentication is mandatory before any mail transfer, ensuring secure access, and the server responds with queued messages or errors like 453 (no mail available) or 451 (temporary processing issue).[67] Commands such as EXPN and VRFY are explicitly not supported, returning 502 errors to maintain focus on relay functions, while providers must implement timeouts of at least 10 minutes for ATRN requests to accommodate variable connection speeds.[67] This protocol enhances relay flexibility by allowing on-demand pulls, but it requires firewall accommodations for port 366 and careful queue management on the provider side.[67]
Security Considerations
TLS and Encryption Methods
The Simple Mail Transfer Protocol (SMTP) originally operated over unencrypted TCP connections, exposing email transmissions to eavesdropping and tampering. To address these vulnerabilities, the STARTTLS extension was introduced to enable opportunistic encryption by upgrading an existing plain SMTP session to Transport Layer Security (TLS). Defined in RFC 3207, STARTTLS operates as an SMTP service extension advertised via the EHLO command with the keyword "STARTTLS" and no parameters.[79] Upon receiving the STARTTLS command from a client, a compliant server responds with a 220 status code indicating readiness for TLS negotiation; the client then initiates the TLS handshake, after which the SMTP session resets to its initial state, requiring a new EHLO to resume operations.[79] This mechanism ensures that TLS is applied at the transport layer without altering the core SMTP protocol, though it introduces risks such as man-in-the-middle attacks if the initial plain-text exchange is intercepted before the upgrade.[79] STARTTLS supports two primary modes of operation: opportunistic and mandatory. In opportunistic mode, clients attempt to initiate TLS but proceed with unencrypted transmission if the server does not support or advertise the extension, providing a balance between security and compatibility for inter-domain email relay.[79] Mandatory mode, conversely, requires TLS for the session; servers may reject connections with a 530 error if STARTTLS is not issued, though publicly referenced SMTP servers on port 25 must not enforce this for local mail delivery to avoid disrupting standard operations.[79] Certificate validation in both modes traditionally relies on public key infrastructure (PKI) with certificates issued by trusted certificate authorities (CAs), where clients verify the server's identity against the hostname in the certificate's subject or subject alternative name fields.[79] An alternative validation method, DNS-based Authentication of Named Entities (DANE), uses DNSSEC-secured TLSA resource records published under the subdomain_25._tcp.<domain> to specify acceptable server certificates or public keys, enabling validation independent of CAs.[80] DANE records support usages such as DANE-EE(3) for direct end-entity certificate matching or DANE-TA(2) for trust anchor validation, and in opportunistic TLS contexts, clients fall back to unauthenticated encryption or cleartext if no valid TLSA records are found.[80]
As a legacy alternative to STARTTLS, SMTPS employs implicit TLS, where the connection begins with TLS negotiation immediately upon TCP establishment, without an initial plain-text phase.[44] Historically registered for SMTP over SSL in 1997 but deprecated and reassigned by the Internet Assigned Numbers Authority (IANA) in 1998 due to lack of standardization, port 465 for SMTPS saw widespread de facto adoption for secure message submission despite the revocation.[44] RFC 8314 later formalized its use on port 465 as a recommended implicit TLS option alongside STARTTLS on port 587, citing improved resistance to downgrade attacks, though both require certificate validation per established TLS practices.[44] While considered deprecated in favor of explicit STARTTLS methods in earlier guidance, SMTPS remains in use for legacy systems and transitional deployments to phase out cleartext email submission.[44]
