Hubbry Logo
Simple Mail Transfer ProtocolSimple Mail Transfer ProtocolMain
Open search
Simple Mail Transfer Protocol
Community hub
Simple Mail Transfer Protocol
logo
7 pages, 0 posts
0 subscribers
Be the first to start a discussion here.
Be the first to start a discussion here.
Simple Mail Transfer Protocol
Simple Mail Transfer Protocol
from Wikipedia

Simple Mail Transfer Protocol
Communication protocol
AbbreviationSMTP
PurposeElectronic mail transmission protocol
IntroductionNovember 1981; 43 years ago (1981-11)
OSI layerApplication layer
Port(s)465, 587, 25
RFC(s)5321

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]
Blue arrows depict implementation of SMTP variations.

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:

  1. MAIL command, to establish the return address, also called return-path,[24] reverse-path,[25] bounce address, mfrom, or envelope sender.
  2. 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.
  3. 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.com
C: Date: Tue, 15 Jan 2008 16:02:43 -0500
C: Subject: Test message
C:
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:

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:

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:

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]

Notes

[edit]

References

[edit]

Further reading

[edit]
[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
The Simple Mail Transfer Protocol (SMTP) is the foundational Internet standard protocol for the reliable and efficient transmission of electronic mail between message transfer agents (MTAs), such as email servers. It operates as a client-server application-layer protocol over TCP/IP, defining a text-based command-response interaction to transfer mail messages independently of the underlying transmission subsystem, requiring only a reliable ordered data stream channel. Originally specified in RFC 821 in August 1982, SMTP was updated and consolidated in RFC 2821 in April 2001 before being further clarified and revised in RFC 5321 in October 2008, which remains the current core specification as of November 2025, with an updated version (RFC 5321bis) approved for publication. In operation, an SMTP session begins with the client connecting to the server, typically on TCP port 25 as assigned by the (IANA), and issuing an initial greeting command like HELO (for basic SMTP) or EHLO (for Extended SMTP, or ESMTP). The client then specifies the sender with the MAIL FROM command, designates recipients via RCPT TO, and transmits the content using the command, concluding with a QUIT command to end the session. This push-based model enables MTAs to relay messages across networks, with servers accepting valid mail for local delivery or further forwarding, while rejecting invalid attempts through response codes. SMTP's simplicity supports its widespread use, though it assumes a trusted network environment without built-in or in its base form. To address modern security needs, SMTP has been extended via ESMTP mechanisms outlined in RFC 5321, incorporating features like STARTTLS for and protocols such as AUTH to prevent unauthorized relaying and spam. Additional ports, including 587 for secure message submission (as defined in RFC 6409) and 465 for message submission using implicit TLS (as defined in RFC 8314), complement port 25 for client-to-server interactions in secure environments. As the primary protocol for transport, SMTP underpins global email infrastructure, handling approximately 376 billion messages daily as of 2025 while integrating with related standards like RFC 5322 for message formats.

History

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 in the early 1970s. Prior to networked capabilities, programs like MIT's MAILBOX in 1965 allowed users on the same system to exchange messages stored in a shared file, but these were confined to single machines without inter-host communication. 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. 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. 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 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). 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 that hindered across diverse 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 text messages with structured headers for fields like From, To, and Subject, facilitating broader compatibility. This format standard helped pave the way for SMTP as a dedicated transfer protocol to overcome the inefficiencies of FTP-based relays.

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. This document established SMTP as an for the reliable and efficient transfer of electronic mail messages between hosts, independent of specific transmission subsystems. It defined a process-to-process communication standard, building briefly on earlier mail systems to create a more structured framework for internetwork mail exchange. 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. 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. 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. 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. 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. This separation allowed SMTP to focus on transport while RFC 822 governed the structured representation of mail data.

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 . As email usage proliferated in the late 1980s and early 1990s, driven by the and the growth of online communities, SMTP's original design—optimized for small-scale 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 . 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 (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 . By the early 2000s, the explosive growth of —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 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 (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 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 , where had become a primary communication medium handling billions of messages annually. 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 Standards Track, it clarified operational details, improved loop detection, and aligned the protocol with 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.

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. 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 clients, validating and preparing them for entry into the SMTP network before passing them to MTAs. 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. SMTP distinguishes between the message and the message content to facilitate efficient . The 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 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.

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 records to identify the appropriate mail exchanger host.RFC 5321, Section 5.1 The lookup involves querying the domain for mail exchanger records ordered by preference value, starting with the lowest; if no 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 .RFC 5321, Section 5.1 Upon successful connection, the server immediately sends a 220 greeting response containing its domain name and a , 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 to identify itself; the server responds with a 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 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 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 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 (.); the server then closes the data channel and sends upon successful receipt.RFC 5321, Section 4.1.1.4 Sessions incorporate error handling through three-digit reply codes: 4xx codes indicate transient failures (e.g., 421 for service unavailable or for a temporary mailbox issue), prompting the client to retry later, while 5xx codes denote permanent errors (e.g., 550 for requested action not taken or 553 for malformed address), advising against further attempts for that transaction.RFC 5321, Section 4.2.1 Retry mechanisms for 4xx responses should employ , with an initial minimum delay of 30 minutes and persistence up to 4-5 days before abandonment, ensuring reliable delivery without overwhelming the server.RFC 5321, Section 4.5.4.1 To terminate the session, the client sends the QUIT command, to which the server replies with 221 and closes the connection, resetting any pending transaction state.RFC 5321, Section 4.1.1.10 If the connection closes prematurely without QUIT, the server may treat it as an implicit quit but logs the event accordingly.RFC 5321, Section 3.8

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 and line feed (CRLF) terminators. 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 syntax HELO SP domain CRLF, where domain is the of the sending host; it has no effect on transaction buffers and can be issued at any time. 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. 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. 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>). 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. The NOOP command performs no action but confirms the connection's viability, with syntax NOOP [SP string] CRLF, often used for keep-alives. Finally, the QUIT command terminates the SMTP session gracefully, using QUIT CRLF, after which the server closes the transmission channel. 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 following a valid HELO or MAIL FROM, indicating the action was accepted and the client may proceed. A 3xx code requests further action from the client, exemplified by 354 Start mail input; end with . after , signaling the server is ready for content. 4xx codes indicate temporary failures that may warrant retry, like 421 4.4.2 Service not available or 450 Requested mail action not taken: mailbox unavailable, often due to transient issues such as resource limits. 5xx codes denote permanent failures, such as 550 5.1.1 User unknown or 552 5.3.4 Requested mail action aborted: exceeded storage allocation, advising against immediate retries without changes. Each response line is limited to 512 octets, and servers may provide multi-line replies by repeating the first three digits followed by a , ending with a space for the final line.
CommandSyntaxPurposeTypical Response
HELOHELO SP domain CRLFClient identification250 domain OK
MAIL FROMMAIL FROM: SP <reverse-path> CRLFStart transaction, specify sender250 2.1.0 Sender OK
RCPT TORCPT TO: SP <forward-path> CRLFAdd recipient250 2.1.5 OK
DATADATA CRLF (followed by message ended by <CRLF>.<CRLF>)Transmit message354 Start mail input; 250 2.0.0 OK
RSETRSET CRLFReset transaction250 2.0.0 OK
NOOPNOOP [SP string] CRLFNo operation, connection check250 2.0.0 OK
QUITQUIT CRLFEnd session221 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 from originating sources to destination systems. 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. In contrast, an MSA serves as a submission server that accepts messages directly from Mail User Agents (MUAs), such as clients, and either delivers them locally or relays them to an MTA for further transport. 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 . Configuration of outgoing mail servers involves setting up listening interfaces on designated ports, implementing message queuing for delivery retries, and leveraging (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. MSAs, however, utilize port 587 for message submission via Extended SMTP (ESMTP), enabling secure and authenticated handoffs from user agents. 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. 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. The distinction between submission and relay servers underscores their specialized roles in outgoing mail handling. Submission servers (MSAs on 587) are designed for initial intake from authenticated users, often allowing modifications like adding missing headers (e.g., Date or ) to ensure compliance, and they reject malformed submissions immediately with codes. Relay servers (MTAs on 25), by comparison, facilitate transfers between mail systems without altering content, focusing on efficient forwarding while enforcing stricter policies to prevent abuse. This separation enhances and reliability, as submission ports support user authentication and are isolated from open relaying risks inherent in traditional MTA operations.

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. 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. 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. Some email service providers utilize TCP port 2525 as a non-standard alternative, particularly in environments where traditional ports are unavailable. SMTP connectivity is fundamentally TCP-based, with the client initiating a to the server's listening to open a reliable, ordered stream for command-response exchanges. Upon successful connection, the server issues a "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. 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 for retries on transient failures. Firewall and (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. 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. 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 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 the mynetworks or smtpd_client_restrictions to explicitly allow specific IP ranges or hosts before applying broader rejection policies. extends this by denying connections from IP addresses associated with certain countries, leveraging geolocation databases integrated into access controls, as implemented in systems like Email Security Appliance where sender groups can reject mail based on geographic origin. 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. Starting in 2024, major email providers including , Yahoo, and have implemented requirements for bulk email senders (over 5,000 emails per day) to authenticate via (SPF), (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. 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. 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). 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. 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. To further mitigate abuse such as denial-of-service attacks or spam floods, SMTP servers implement , 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. 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). These techniques are often combined, with greylisting applied early in the SMTP dialog and exceptions for authenticated or whitelisted clients to minimize disruption.

Operational Mechanics

SMTP Transport Example

A typical SMTP example illustrates the protocol's client-server dialogue for transferring an 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 , followed by optional , envelope specification, recipient validation, data transmission, and session termination. The example below depicts a where a client at client.example.com sends mail to multiple recipients at mail.example.com, incorporating Extended SMTP (ESMTP) via the EHLO command and optional using the AUTH extension for PLAIN mechanism over TLS (though TLS is omitted here for brevity; in practice, STARTTLS would precede AUTH). 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., for service ready, 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.

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)

This example highlights SMTP's relay denial protection: without authentication or trusted IP, a 550 "Relay access denied" might occur after MAIL FROM if the sender or recipients are not authorized. For single-recipient cases, the flow simplifies by using one RCPT TO, reducing overhead while maintaining the same structure. In production, variations include TLS (via STARTTLS after EHLO) to secure the entire , especially for AUTH.

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. 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 (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 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. 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 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.

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 for storage in user mailboxes or further handling. MDAs such as receive messages from the Mail Transfer Agent (MTA) and apply filters, sort content, or deliver directly to spool files or formats, ensuring efficient local placement without network transmission. , 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. 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. For remote delivery, SMTP relies on relay servers that forward messages across networks using MX records from the (DNS) to determine the next hop, with preferences guiding the order of attempts. 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. This enables recipients to retrieve accumulated mail on demand, with sessions supporting timeouts of at least 10 minutes to accommodate variable connection times. 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 for delivery. 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. Virtual domains are handled through DNS records, which map domain names to hosting servers; multiple records with preference values enable load balancing or , treating the domain as a logical entity independent of physical hosts. CNAME records further support aliasing at the domain level, recursively resolving to canonical names before queries. Queuing precedes these mechanisms as an interim step, buffering messages for routing attempts.

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 or an address literal, such as EHLO [example.com](/page/Example.com). 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. 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. 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. 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. 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. 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 . 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. This ensures robust , as servers must not offer capabilities they cannot fulfill and clients must not attempt parameters beyond those explicitly advertised.

Data Transfer and Format Extensions

The Simple Mail Transfer Protocol (SMTP) originally supported only 7-bit ASCII text, necessitating encodings like or 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 . These extensions are advertised by servers in response to the EHLO command, enabling clients to negotiate their use during the SMTP session. 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. 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. 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. 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. 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. 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. 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). The MAIL command may include a BODY=BINARYMIME parameter, and receivers must preserve all octet bits while enforcing canonical line endings for text parts. BINARYMIME is incompatible with the standard DATA command in the same transaction but can integrate with PIPELINING for improved performance; senders must convert unsupported binary data to 8-bit or 7-bit forms without loss if the extension is unavailable. The extension, defined in RFC 1870, allows clients to declare the size of a message in advance, enabling servers to reject oversized messages early and optimize resource allocation during sessions. Servers advertise support via the "SIZE" EHLO keyword, optionally followed by a indicating their maximum accepted message size in bytes as a number (e.g., SIZE=); a value of or omission signifies no fixed limit. Clients then include a "SIZE=value" in the MAIL FROM command, where value is the estimated total octets including pairs but excluding the DATA-terminating dot-stuffing. If the declared size exceeds the server's limit, it responds with a 552 error for permanent failure or 452 for temporary issues like insufficient resources, potentially at the RCPT stage on a per-recipient basis. Servers may accept messages larger than declared if resources permit, and clients should provide accurate estimates to avoid unnecessary rejections.

Internationalization 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. This framework replaces earlier efforts like RFC 4952 and relies on encoding to support characters in email addresses, headers, and related protocols. 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. Implementation requires systems to support the 8BITMIME extension (RFC 6152) for transmission, and domain names must conform to Internationalizing Domain Names in Applications (IDNA) standards (RFC 5890) using A-labels or U-labels. The SMTPUTF8 extension, specified in RFC 6531, extends the Simple Mail Transfer Protocol (SMTP) to permit strings in addresses, headers, and the message body, facilitating global email interoperability. 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. In the MAIL and RCPT commands, internationalized addresses follow an extended syntax from RFC 5321, where local parts and domain names may include characters, with domains resolved via IDNA-compliant DNS lookups using A-labels. Clients must specify the SMTPUTF8 parameter in the command if using , and servers are required to reject messages with non-ASCII content if they lack support, using enhanced SMTP error codes such as 5.6.7 for invalid syntax or 5.6.9 for permanent failures related to . This extension mandates 8BITMIME support to handle the full range of octets, preventing during transit, though it introduces risks of rejection if downstream servers do not support it, emphasizing the need for gateway downgrading only at message endpoints. On-Demand Mail Relay (ODMR), outlined in RFC 2645, introduces a pull-based mechanism for authenticated email retrieval, contrasting with SMTP's traditional push model and aiding environments with dynamic IP addresses, such as mobile or dial-up systems. Operating on port 366, ODMR reverses client-server roles after authentication: the client initiates an ODMR session, authenticates using SASL mechanisms like CRAM-MD5 (RFC 2195), and then requests queued mail via the ATRN command, specifying one or more domains in the syntax ATRN [SP domain *("," domain)]. 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). 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. 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.

Security Considerations

TLS and Encryption Methods

The Simple Mail Transfer Protocol (SMTP) originally operated over unencrypted TCP connections, exposing email transmissions to and tampering. To address these vulnerabilities, the STARTTLS extension was introduced to enable by upgrading an existing plain SMTP session to (TLS). Defined in RFC 3207, STARTTLS operates as an SMTP service extension advertised via the EHLO command with the keyword "STARTTLS" and no parameters. Upon receiving the STARTTLS command from a client, a compliant server responds with a status code indicating readiness for TLS negotiation; the client then initiates the TLS , after which the SMTP session resets to its initial state, requiring a new EHLO to resume operations. This mechanism ensures that TLS is applied at the 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. 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. 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. Certificate validation in both modes traditionally relies on (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. An alternative validation method, (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. DANE records support usages such as DANE-EE(3) for direct end-entity certificate matching or DANE-TA(2) for validation, and in contexts, clients fall back to unauthenticated encryption or cleartext if no valid TLSA records are found. 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. Historically registered for SMTP over SSL in 1997 but deprecated and reassigned by the (IANA) in 1998 due to lack of standardization, port 465 for saw widespread de facto adoption for secure message submission despite the revocation. 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. While considered deprecated in favor of explicit STARTTLS methods in earlier guidance, remains in use for legacy systems and transitional deployments to phase out cleartext email submission.

Authentication and Reporting Extensions

The Simple Mail Transfer Protocol (SMTP) has been extended to include mechanisms for client-server and reporting of security-related events, enhancing beyond basic transport encryption. These extensions, introduced through specific RFCs, allow for identity verification during SMTP sessions and systematic notification of TLS failures, helping operators detect and mitigate issues such as misconfigurations or attacks. While STARTTLS provides the foundational for these features, the authentication and reporting extensions focus on verifying participants and logging anomalies post-negotiation. SMTP-AUTH, defined in RFC 4954, enables SMTP clients to authenticate to servers using the (SASL), allowing for the negotiation of a protected SMTP session. This extension is advertised by servers in response to the EHLO command via the "AUTH" keyword, followed by a space-separated list of supported SASL mechanisms, such as , , CRAM-MD5, DIGEST-MD5, or GSSAPI. Upon receiving the AUTH command from a client specifying a mechanism (e.g., AUTH ), the server responds with a continuation code (334), prompting the client to send credentials in the SASL exchange; successful authentication results in a 235 response code. Servers must support the AUTH parameter in the MAIL FROM command to associate an authenticated mailbox with the sender's identity, even if no prior client authentication occurred. For security, plaintext mechanisms like require TLS protection to prevent eavesdropping, and clients are mandated to verify server certificates when using such mechanisms over TLS. RFC 4954 obsoletes the earlier RFC 2554 and emphasizes interoperability, requiring implementations to support over TLS and optionally CRAM-MD5. MTA-STS, outlined in RFC 8461, provides a framework for mail service providers to declare and enforce strict (TLS) requirements for incoming SMTP connections, mitigating risks from opportunistic STARTTLS downgrades or interceptions. Domains publish an MTA-STS policy indicator via a DNS at the subdomain "_mta-sts.", which includes a version tag ("v=STSv1") and a unique policy identifier ("id"), such as "_mta-sts.example.com. IN TXT "v=STSv1; id=20160831085700Z;"". Sending mail transfer agents (MTAs) query this record to discover the policy, then retrieve the full policy document over from "https://mta-sts./.well-known/mta-sts.txt", which specifies the mode (enforce, testing, or none), maximum age in seconds (up to 31,557,600), and permitted MX host patterns. In "enforce" mode, sending MTAs must refuse delivery if TLS negotiation fails—such as when STARTTLS is unsupported or the certificate is invalid according to PKIX validation—ensuring all connections use authenticated TLS. The "testing" mode allows delivery while generating reports of failures, and "none" disables the policy. This mechanism does not require DNSSEC but relies on for policy confidentiality and authenticity, with DNSSEC providing optional protection for the TXT record against . SMTP TLS Reporting, specified in RFC 8460, establishes a standardized method for sending MTAs to report aggregate statistics on TLS connection outcomes to recipient domains, aiding in the identification of issues without exposing sensitive per-message details. Domains advertise reporting endpoints via a DNS at "_smtp._tls.<-domain>", containing "v=TLSRPTv1" and one or more "rua=" URIs (: or :) for report submission, such as "_smtp._tls.example.com. IN TXT "v=TLSRPTv1; rua=:[email protected]"". Reports are generated periodically (e.g., daily) and formatted as I-JSON objects, including metadata like the reporting organization's domain, contact information, report date range, and details (e.g., MTA-STS or DANE enforcement). The core of each report is an array of aggregate counts for TLS sessions to specific MX hosts, categorized by outcome types such as "success" (valid TLS established), "starttls-not-supported", "certificate-expired", or "validation-failed", with optional additional-information URIs for diagnostics. Reports distinguish between domains (typically the recipient domain) and MX domains, supporting multiple policies per domain and focusing on failures from , DNS resolution, STARTTLS , or certificate validation to enable proactive issue resolution.

Anti-Spoofing and Spam Mitigation

One of the primary vulnerabilities in the Simple Mail Transfer Protocol (SMTP) is the ability to forge the sender's address in the MAIL FROM command, allowing unauthorized parties to impersonate legitimate domains without . This lack of inherent verification in SMTP enables , where malicious actors can inject deceptive messages into the system. The rise of unsolicited bulk email, or spam, exploiting these weaknesses became prominent in the 1990s, with the first widespread commercial spam campaigns emerging around 1994 and escalating into an epidemic by the late decade, overwhelming email infrastructure and eroding user trust. To counter sender spoofing, several domain-based authentication mechanisms have been developed as SMTP extensions. The Sender Policy Framework (SPF), defined in RFC 7208, allows domain administrators to publish DNS records specifying authorized IP addresses or hosts permitted to send on behalf of their domain, enabling receiving servers to validate the 's envelope against these policies. (DKIM), outlined in RFC 6376, addresses by using to sign emails, permitting recipients to verify that the content and headers have not been altered in transit and originate from an authorized signer within the domain. Building on SPF and DKIM, Domain-based Message Authentication, Reporting, and Conformance (DMARC), specified in RFC 7489, provides a framework for domain owners to set policies on handling messages that fail authentication checks, along with reporting tools to monitor abuse and refine protections. These methods collectively reduce spoofing by establishing verifiable claims about identity and authenticity, often integrated as complementary to extensions. In addition to protocol-level mitigations, server-side filtering techniques play a crucial role in spam detection and prevention within SMTP environments. Content scanning examines email bodies, headers, and attachments for patterns indicative of spam, such as suspicious keywords, URLs, or signatures, often using heuristic rules or models to assign risk scores. Bayesian analysis enhances this by applying : it trains on labeled datasets of legitimate and spam messages to compute the likelihood of new emails being unsolicited based on word frequencies and contextual features, achieving high accuracy in adaptive filtering. Relay restrictions further limit abuse by configuring SMTP servers to reject from unauthorized sources or prevent open relaying, where external senders could use the server as an intermediary for bulk distribution, a common vector for spam in early SMTP deployments.

Implementations and Usage

Open-Source Implementations

Postfix, first released in 1998 by Wietse Venema while at , is a modular mail transfer agent (MTA) designed as a secure and efficient alternative to earlier systems like . Its architecture emphasizes queue management through separate processes for incoming SMTP connections, message queuing, and delivery, reducing the risk of vulnerabilities from long-running daemons. Postfix includes built-in anti-spam features such as sender restrictions, recipient verification, and integration with external filters, while maintaining full compliance with SMTP standards defined in RFC 5321. Exim, initially developed in 1995 by at the Computing Service as a replacement for Smail 3, is a highly configurable MTA tailored for systems. Its single-configuration-file approach enables scriptable logic for complex routing decisions, including policy-based controls via access control lists (ACLs) introduced in version 4. Exim supports advanced features like virtual domains, content scanning, and per-host retry mechanisms, allowing administrators to implement custom delivery rules without recompiling the software. Like other open-source MTAs, it adheres to core SMTP protocols for reliable message transfer. Sendmail, the original open-source MTA authored by in 1981 at the , under a contract, laid the foundation for SMTP-based email routing on Unix systems. Initially focused on internetwork mail delivery across diverse transport protocols, it has evolved with modern extensions in its open-source releases, such as support for TLS encryption and integration with OpenDKIM for domain authentication per RFC 4871. Current versions, like 8.18.1, retain backward compatibility while adding features for large-scale environments, including queue prioritization and aliasing. For lightweight client-side use, tools like sSMTP provide a simple send-only interface to forward messages to an SMTP server without full MTA overhead.

Commercial and Enterprise Solutions

provides an integrated SMTP solution for enterprise email environments, enabling seamless mail transfer within on-premises deployments and through Exchange Online in Microsoft 365. Exchange Online utilizes SMTP protocols for outbound email submission, supporting methods such as client SMTP submission over port 587 with TLS encryption and authentication, which integrates directly with Outlook clients to handle sending limits of up to 10,000 recipients per day. Hosted on Azure infrastructure, it offers scalable relay options via inbound connectors for higher-volume scenarios, ensuring compliance with enterprise requirements like SPF, DKIM, and authentication to prevent spoofing. The Cisco Secure Email Gateway (ESA), formerly known as IronPort Email Security Appliance, serves as a proprietary SMTP gateway appliance focused on inbound and outbound email relay with advanced filtering capabilities for enterprise networks. In outbound relay mode, the ESA functions as a dedicated Mail Transfer Agent (MTA), handling high-volume SMTP traffic while supporting configurations for relay hosts to route emails through specified external servers, enhancing delivery reliability in large-scale deployments. Its gateway filtering integrates anti-spam, anti-virus, and content scanning to inspect SMTP streams before relay, providing enterprise-grade protection against threats without disrupting mail flow. Proofpoint offers Secure Email Relay (SER), a cloud-based SMTP proxy service designed for enterprise application email, ensuring secure relay from approved sources to mitigate risks like domain spoofing and unauthorized sending. This solution proxies SMTP traffic by applying DKIM signing for DMARC compliance, scanning for malware and sensitive data via data loss prevention (DLP), and enforcing authenticated relay to block impersonation attempts in hybrid or cloud environments. Similarly, Mimecast's Secure Email Gateway provides a cloud-native SMTP proxy that intercepts and filters inbound/outbound email flows, leveraging AI-driven detection, as 91% of cyber attacks start with email, while supporting compliance through customizable policies and integrations with Microsoft 365. These enterprise solutions often incorporate ESMTP extensions for enhanced security features like STARTTLS and authentication.

Historical and Legacy Systems

Sendmail emerged as the dominant mail transfer agent (MTA) in the early 1980s, implementing SMTP as early as November 1981 and influencing its standardization in RFC 821 the following year. Developed by at UC Berkeley, it was distributed with BSD Unix releases starting in 1983, rapidly becoming the standard for routing email across the nascent and early , where it handled messages between diverse networks with varying addressing schemes. Its configurability via the m4 macro language allowed adaptation to complex environments, solidifying its prevalence on Unix systems and beyond. However, Sendmail's early designs prioritized functionality over security, often running with root privileges and exposing vulnerabilities like the debug mode in versions prior to 5.61. This flaw was infamously exploited by the on November 2, 1988, which used the debug mode to execute arbitrary commands on infected systems, contributing to the worm's spread across approximately 6,000 Unix machines—about 10% of the at the time. The incident, analyzed in detail by Eugene Spafford, underscored Sendmail's security shortcomings and prompted widespread patches and a shift toward more secure practices in MTA development. To address ongoing extensibility needs while enhancing security, introduced the Mail Filter (Milter) in version 8.10 around 1998, with full official support in version 8.12 released in September 2001. This architecture allows third-party filters to intercept and modify messages during SMTP processing in separate, non-root processes, enabling safer integration of features like antivirus scanning and spam detection without altering 's core. Many legacy deployments migrated to this model to mitigate vulnerabilities while retaining compatibility with older configurations. In response to Sendmail's security issues, Daniel J. Bernstein developed qmail starting in December 1995 as a secure alternative MTA, emphasizing principles like avoiding setuid programs, minimizing root operations, and modular design to prevent common exploits. qmail included a security guarantee offering a $500 reward for verifiable holes since March 1997, with no successful claims, establishing its reputation for robustness in handling high-volume email without the vulnerabilities seen in contemporaries. However, Bernstein ceased active maintenance after version 1.03 in 1998, leaving qmail unmaintained by its author amid disputes over licensing and patches. Community efforts filled this gap, with netqmail emerging as a key in 2002, incorporating fixes, feature enhancements like better , and compatibility improvements from -1.03, though its last official release was in 2007. Subsequent forks, such as notqmail launched in 2019, continue this lineage with collaborative updates for modern environments, but original and early forks remain in use on legacy systems due to their proven reliability. By 2025, legacy SMTP systems like older and installations face significant challenges in compatibility with modern extensions, particularly SMTPUTF8 defined in RFC 6531 (2012), which enables encoding for internationalized addresses and headers. These systems, lacking native SMTPUTF8 support, often reject messages containing non-ASCII characters in domains or local parts, returning errors like 550 or 553, as they rely on 7-bit ASCII transport per original SMTP specifications. Migration efforts are complicated by the need to preserve compatibility with vast archives of ASCII-only mail, while global growth—exceeding 376 billion messages daily as of 2025—demands support for multilingual content, forcing administrators to deploy gateways or upgrades to avoid delivery failures.

References

Add your contribution
Related Hubs
User Avatar
No comments yet.