If you think of e-mail as elec­tron­ic mail, then SMTP is the mail man. Without the internet’s standard network protocol, sending ap­plic­a­tions documents, e-cards, and funny cat videos wouldn’t be possible at all. This is because when you send an e-mail, it doesn’t simply travel directly to the recipient, but goes through a complex com­mu­nic­a­tion process with numerous instances before it reaches its des­tin­a­tion.

Free Cloud Server Trial
En­ter­prise-grade virtual private servers
  • KVM based dev servers for de­velopers
  • Scalable to en­ter­prise cloud level
  • Pay-as-you-go, per-minute billing

What is the SMTP protocol?

SMTP stands for “Simple Mail Transfer Protocol.” It is a con­nec­tion-ori­ent­ated, text-based network protocol from the internet protocol family and is located on the seventh layer of the OSI model: the ap­plic­a­tion layer. Just like any other network protocol, it contains rules for correct com­mu­nic­a­tion between computers in a network. SMTP is re­spons­ible for feeding and for­ward­ing e-mails from sender to recipient.

Since its release in 1982 as the successor of the “Mail Box Protocol” in Arpanet, SMTP has become the standard protocol for sending e-mails. For the average consumer, however, the SMTP protocol remains largely invisible, since the re­spect­ive e-mail program executes it in the back­ground. If the software, the webmail ap­plic­a­tion in the browser, or the mobile mail app don’t auto­mat­ic­ally define the SMTP protocol when setting up an account, you have to set it up manually to ensure smooth e-mail traffic.

Fact

Sendmail was one of the first Mail Transfer Agents (MTA) that supported the SMTP protocol.

Here is an overview of SMTP server addresses and SMTP ports for some of the most popular e-mail providers.

E-mail provider SMTP server address SMTP port
Yahoo smtp.mail.yahoo.com 465
AOL smtp.aol.com 587
Outlook smtp.live.com 587
Gmail smtp.gmail.com 587 (TLS/STARTTLS), 465 (SSL)

How does SMTP work?

To un­der­stand the SMTP protocol, you first have to un­der­stand e-mail. This is basically how it works:

  1. The SMTP client, i.e. the sender, loads the e-mail onto the SMTP server, i.e. the outgoing mail server of the re­spect­ive e-mail provider. This is done via a webmail ap­plic­a­tion in the browser or an e-mail program (tech­nic­ally called “Mail User Agent,” MUA for short) such as Windows Live Mail or Mozilla Thun­der­bird.
  2. The SMTP server then contacts the DNS server, and this server then searches for the IP address of the target SMTP server (also called “Mail Delivery Agent,” MDA for short), which is stored for the recipient address of the e-mail.
  3. The SMTP server sends the e-mail to the target SMTP server via one or more “Mail Transfer Agents” (MTA). Each of these for­ward­ing processes runs according to the SMTP protocol.
  4. The target SMTP server tem­por­ar­ily stores the e-mail in the message store.
  5. The recipient MUA downloads the e-mail either via IMAP or POP3.

How does an SMTP session work?

The in­ter­ac­tion between the SMTP client and the SMTP server mentioned in the first step of the SMTP procedure rep­res­ents the actual SMTP session. The rest of the SMTP procedure i.e. for­ward­ing the e-mail via SMTP from the server to the recipient is covered in a separate article. Each session consists of a sequence of SMTP commands from the client and responses in the form of status codes from the server.

Overview of SMTP commands

According to the ap­plic­able SMTP spe­cific­a­tions, each im­ple­ment­a­tion of the network protocol must support at least the following eight commands, con­sist­ing of 7-bit ASCII char­ac­ters:

SMTP command Meaning
HELO “Hello.”– the client logs on with its computer name and starts the session
MAIL FROM The client names the sender of the e-mail
RCPT TO “Recipient” – the client names the recipient of the e-mail
DATA The client initiates the trans­mis­sion of the e-mail
RSET The client ter­min­ates the initiated trans­mis­sion, but maintains the con­nec­tion between client and server
VRFY/EXPN “Verify”/“Expand”– the client checks whether a mailbox is available for message trans­mis­sion

Overview of server status codes

The server responds to each of these SMTP commands of the client with a three-digit status code including plain text message:

Status code Plain text message
Status codes that indicate that the server has suc­cess­fully carried out the command:
200 (Non-standard success)
211 System status or system help reply
214 Help message
220 Server ready for SMTP session
221 Server ends the con­nec­tion
250 Requested mail action OK, completed
251 User not local; mail is forwarded
252 Cannot verify (VRFY) user, but will accept message and attempt delivery
253 Pending messages for node started
Status codes that indicate that the server has un­der­stood the command, but requires further in­form­a­tion for pro­cessing:
354 Server starts mail input
Status codes that indicate that the server has detected a temporary error, but that the command may still be processed:
421 Server not available, con­nec­tion is ter­min­ated
450 Commando not executed, mailbox un­avail­able
451 Requested action aborted: local error in pro­cessing
452 Requested action not taken: in­suf­fi­cient system storage
Status codes that indicate that the server has detected a fatal error and the command cannot be processed:
500 Syntax error, command un­re­cog­nised
501 Syntax error in para­met­ers or arguments
502 Command not im­ple­men­ted
503 Bad sequence of commands
504 Command parameter not im­ple­men­ted
521 Server doesn’t accept any mails
530 Access denied; au­then­tic­a­tion required
550 Requested action not taken: mailbox un­avail­able
551 User not local; please try forward path
552 Requested mail action aborted: exceeded storage al­loc­a­tion
553 Requested action not taken: mailbox name not allowed
554 Trans­ac­tion failed

SMTP example session

An example of an SMTP session between client and server could be as follows:

Tip

Email hosting from IONOS means you can com­mu­nic­ate pro­fes­sion­ally and safely, all at a reas­on­able price. Use per­son­al­ized email addresses with your own domain, flexible access to your mails at any time, archiving function, calendar and office solution and much more. Rely on the highest security standards too, with IONOS' ISO-certified data centers.

What are the dis­ad­vant­ages of the SMTP protocol?

The dis­ad­vant­age of SMTP is that users are not verified when a con­nec­tion is es­tab­lished, meaning that the sender of an e-mail might not be trust­worthy. As a result, open SMTP relays are often used to send spam on a massive scale. The spammers use fake sender addresses so that they cannot be traced (mail spoofing). Today, there are many security tech­no­lo­gies in use to prevent SMTP servers from being abused. For example, sus­pi­cious e-mails are rejected or moved to quar­ant­ine (spam folder). The iden­ti­fic­a­tion protocol Do­main­Keys (DK), the Sender Policy Framework (SPF), or greylist­ing can be used for this purpose. In addition, it has become more or less standard to receive e-mails not only via the tra­di­tion­al port 25/TCP, but also via port 587/TCP, so that trans­mis­sion is only allowed for verified users.

What is ESMTP?

In response to the rampant spam problem on the internet, an extension of SMTP was released in 1995: extended SMTP (ESMTP for short). It adds ad­di­tion­al commands to the protocol in 8-bit ASCII code, enabling many new functions to save bandwidth and protect servers. These include, for example:

  • Au­then­tic­a­tion of the sender
  • SSL en­cryp­tion of e-mails
  • Pos­sib­il­ity of attaching mul­ti­me­dia files to e-mails
  • Re­stric­tions on the size of e-mails according to server spe­cific­a­tions
  • Sim­ul­tan­eous trans­mis­sion to several re­cip­i­ents
  • Stand­ard­ised error messages in case of un­deliv­er­ab­il­ity

Lastly, here are some examples of ESMTP commands:

ESMTP command Meaning
EHLO The al­tern­at­ive to “HELO” in the extended protocol. The client logs on with its computer name and starts the session. If the server supports ESMTP, the session is started suc­cess­fully. Otherwise, the client must use SMTP.
8BITMIME The client prompts the server to allow the 8-bit ASCII character set in the message text.
SIZE The client prompts the server to specify the maximum e-mail size allowed in bytes.
STARTTLS The client asks if the server supports TLS en­cryp­tion.
Go to Main Menu