What Is SMTP? Simple Mail Transfer Protocol Explained

Email is one of the most common methods of communication for individuals and businesses alike. Recent reports show that over 320 billion emails are sent and received daily across the world. You can send emails, receive emails, and even trace emails through the email header. But at the center of all email communication is one important protocol: SMTP. In this post, we've compiled everything you need to know about SMTP, or Simple Mail Transfer Protocol, and their servers - plus how it compares to other email protocols like IMAP - in order to get a basic understanding of how your email really works.

What is SMTP?

SMTP, meaning Simple Mail Transfer Protocol, is the email delivery protocol used for sending emails over the Internet. It runs on the application layer. An email protocol is essentially a set of rules that authenticates the transfer of email messages from one server to another.

Many popular email clients, such as Microsoft Outlook, Yahoo Mail, and Windows Live Mail, use the SMTP Internet protocol to send emails to users. This email protocol keeps users safe by sending authenticated messages into the email inbox on time. Without SMTP, your emails would go nowhere.

As the only dedicated protocol for sending emails, Simple Mail Transfer Protocol is also known as a push protocol because it spells out and pushes messages from the sender to the right recipient. However, at its most basic, SMTP does not excel at queuing incoming messages, so it works closely with protocols that do, such as IMAP or POP3. IMAP and POP3 retrieve messages on the other side.

What is an SMTP server?

An SMTP server is essentially an application that acts as a relay for outgoing emails within a network. Specifically, a Simple Mail Transfer Protocol server handles email deliverability - it sends and relays the messages across a connection.

Consider how emails are routed to user accounts. When you send out an email, an organized system safeguards your envelope, validates it, and takes it through several steps before sending it on to the recipient.

In this case, the computer running SMTP is the SMTP server. It acts like a postman or mail carrier. Once you hit Send, your message transforms into a string of code, which is sent to the SMTP server.

If the server isn't there to process the message, it becomes lost in translation. SMTP works quickly; it takes under a minute for the protocol to complete.

SMTP servers host Simple Mail Transfer Protocol, and like other servers, these servers come with an IP address or addresses that can be set up by the application you're using. The address typically formats as smtp.serveraddress.com. Hypothetically, if you're using a Gmail client, the SMTP server address is smtp.gmail.com. You can easily find your SMTP server address in the Settings section of your mail client account.

Importance of SMTP servers

SMTP servers are crucial to the way our email system functions. They do the following:

  • offer a safe environment for sending emails
  • provide real-time analytics regarding email history
  • verify whether the outgoing messages are from an active account or not
  • provide flexible SMTP and API setup along with dedicated addresses

They have user-friendly software and customizable email integration, both which make the email experience better. Furthermore, without these servers, most emails would land in the recipient's spam folder and be missed.

SMTP is a protocol used in sending emails out from the server.

How does SMTP work?

Simple Mail Transfer Protocol, much like other networking protocols, follows a predefined process for all email sending. SMTP in particular uses the TCP/IP protocol. TCP is a standard Internet communication protocol that allows application programs to exchange data over the Internet.

In this case, the TCP connection guarantees email delivery. This assumes that the destination email address exists and is correct.

SMTP requires two parameters to send mail:

  • the "MAIL FROM," which contains the email address of the sender
  • the "RCPT TO," which specifies the recipients of the message

To understand how SMTP works, look at the sending process.

Technically, when you compose a message using an email client like Microsoft Outlook and then hit Send, the email message travels from your computer to your email server using the SMTP protocol. The message then turns into a string of text to simplify communication. The email server software identifies what they mean.

Next, the email server (also known as the SMTP server) determines which server to send the message to and sends it over to the recipient's email server using SMTP. From there, the incoming message remains until the recipient picks them up by downloading from the server via IMAP or POP.

Note the following about how SMTP functions:

  • Without SMTP, your email won't reach its final destination. It will result in an error message if the email address isn't correct or no longer exists. If the email address is correct, Simple Mail Transfer Protocol sends the mail right away.
  • SMTP server settings tell your email client where to send the email.
  • The email protocol can send a single message to multiple recipients.
  • SMTP can also share emails across networks outside the Internet.
  • Like IMAP and POP3, SMTP is configured in your email client.

Understanding various SMTP commands

SMTP commands are sets of instructions that power the exchange of mail between servers. They tell the server what to do with the accompanying data. Each command plays a significant role in the communication sequence between servers through the Simple Mail Transfer Protocol. The main aim is to deliver emails accordingly.

The eight most frequently-used commands are as follows.

HELO or EHLO

HELO or EHLO is a mandatory command that comes in during the entire email sending process. The main purpose of HELO is to initiate the SMTP session conversation by identifying the client to the server. HELO is often followed by the client's domain name (IP address).

Example: HELO client.net or EHLO client.net

EHLO is the alternative to HELO. Both commands are used to introduce yourself.

MAIL FROM

The MAIL FROM command specifies the sender. It informs the SMTP server who the email is from. For example, a client might send "MAIL FROM:<[email protected]>."

If the sender's email address exists, the SMTP server understands and resets everything ready to accept it. The transfer of the email starts here.

Example: MAIL FROM "[email protected]"

Users know whether the email has been accepted by what comes after. A 250 OK reply code confirms that your message has been accepted. This command is mandatory.

RCPT TO

This command follows MAIL FROM. It identifies the recipient or the addresses where the email is being sent to. RCPT TO includes a destination mailbox. If for any reason the recipients are more than one, the command will specify each recipient separately.

Use one RCPT TO for each addressee if there are multiple addresses.

Example: RCPT TO "[email protected]"

DATA

DATA is another important SMTP command. It specifies the beginning of the mail transfer. The command sends data line by line.

With it, a client asks permission to start the actual transmission. All the mail data moves to the Secure Mail Transfer Protocol server. The reply code 354 given by the server grants permission. At this point, the email is on its way to reaching its destination.

The data transferred includes the date, subject, attachments, and body texts. The last line contains a single dot that signals the end of the email message.

Example:

DATA

354 (server reply code)

Date: Thursday, 12 Dec 2022 04:14:23

From: [email protected]

Subject: What is SMTP?

To: [email protected]

Body text

QUIT

QUIT is the next highly recommended command in the line. It's mainly used to terminate or abort the current SMTP conversation.

The command requests the server to end the session. Once the call is successful, the server will reply with a 221 code.

RSET

The command erases all previous data belonging to all parties involved. From data tables to buffers, RSET resets everything. You can do this whenever there's an error, like using the wrong email address or when the recipient information no longer exists. It allows you to restart the whole process.

EXPN and VRFY

The EXPN command verifies the identification of a mailing list. Does the mailbox in question exist on the local host? A positive response upholds the membership of the recipients.

VRFY, on the other hand, asks the server to verify whether a given username or email address actually exists. Both EXPN and VRFY implement SMTP authentication. They also help perform an internal audit of the SMTP server.

However, these commands lack consistent security. Hackers can use them to collect your personal information, specifically valid email addresses on the server. For this reason, many messaging systems either disable the commands or install corresponding protections.

HELP

Used less frequently, HELP requests valuable information regarding the transfer of an email. HELP mainly identifies the list of commands that the Simple Mail Transfer Protocol server supports.

Understanding SMTP error codes

In some instances, your mail won't send and your SMTP server returns an error message. These error messages mean your email wasn't sent successfully.

Blocks and bounces are some of the issues that prevent a successful email marketing campaign. Simple Mail Transfer Protocol error messages otherwise help figure out why your email sending process failed. They also guide the sender on how to diagnose the problem.

Email delivery roadblocks are daunting at first. Before you panic, be mindful that not all SMTP reply codes are bad. Oftentimes it's just a response containing an answer to a particular command or your server's details.

Some reply codes you normally come across indicate issues like:

  • the email message was marked as having a virus or spam
  • the intended recipient's email address isn't correct
  • the message violated the company's email policy
  • the sender's email address or domain was identified as a source of spam

Some of these SMTP error codes come up rather often. They include 4.X.X errors and 5.X.X errors.

4.X.X Persistent Transient Failure errors are temporary errors. The are the most critical group of errors. Any error code beginning with the number '4' indicates temporary failure. You can fix the error by repeating the command, but these codes keep untrusted senders at bay.

For example, 421 means that the service isn't available due to a connection problem and the session will be closed.

5.X.X Permanent errors are fatal errors. Errors that begin with a '5' indicate this error type. There is no chance to complete the action with another try and no retry will occur. If you resend the email message, chances are you'll get the same error.

Understanding SMTP ports

SMTP ports are communication endpoints that handle the transfer of email data over the protocol. They help route information to the right place. On a network, there are a number of different ports, but only three ports are standardly used for SMTP: port 25, port 465, and port 587.

SMTP port 25 is the default SMTP port, and if you're configuring your mail servers to accept mail from external systems, it needs to be delivered to port 25. However, when you submit a message to be sent, you can use a different port - SMTP port 465 or SMTP port 587.

Note that port 25 is not secure because it's the standard port. This means that while it's used by those trying to send legitimate emails, it's also often used by spammers or hackers. Therefore, for a safer exchange, using port 465 or port 587 is a better option as both those ports are secure.

Comparing SMTP to other email protocols

As mentioned previously, Simple Mail Transfer Protocol is just one of many email protocols. Two other protocols work together with SMTP: IMAP and POP3. SMTP is the only push protocol for sending emails across networks, but IMAP and POP3 are both pull protocols for retrieving emails.

SMTP vs. POP3

POP (Post Office Protocol) retrieves the incoming messages at the receiver's side. The most current version is POP3.

Think of it as a real-life post office. POP3 pulls the messages and holds them on the server until the client logs into the email account to check them out. Many businesses are using this protocol to ensure their employees check incoming messages when offline.

SMTP and POP3 differ in that Simple Mail Transfer Protocol is the email protocol for sending emails, while POP3 is a pull protocol for receiving incoming emails. Furthermore, Simple Mail Transfer Protocol is used twice: once when sending the message between the sender to the Simple Mail Transfer Protocol server and once when pushing the message to the recipient's mail server.

SMTP vs. IMAP

IMAP is the short form for Internet Message Access Protocol. Its primary purpose is to manage and retrieve email messages. IMAP keeps the message on the email server, then authenticates it before synchronizing it to any device. Unlike POP3, IMAP uses a cloud server to validate emails before categorizing them by device.

Simple Mail Transfer Protocol is different from IMAP in that SMTP pushes your e-mails to the recipient's mail server while IMAP handles and retrieves the incoming emails. When used together, both protocols transmit email messages without fail unless otherwise.

SMTP vs. HTTP APIs

SMTP has been in use for nearly four decades. Although it remains a go-to email protocol to send email messages, the future of email deliverability lies in the hands of HTTP APIs.

A trend toward using this cloud-based software to transfer emails is taking a positive trajectory. Cloud-based HTTP APIs allow communication between the email client and the server. The difference between Simple Mail Transfer Protocol and HTTP APIs is that HTTP APIs are faster; they require fewer back-and-forth commands to authenticate the sender and recipients.

Should you run your SMTP server or a third-party email service?

The choice depends on your email sending needs and resources. There are two options when it comes to using a Simple Mail Transfer Protocol server: either you set up your own SMTP server or you use a third-party service. Consider the upsides and downsides of each to figure out which path to go down.

Running your own SMTP client server allows you to fully monitor email delivery. It also means there are no sending volume limits - many other server providers limit your daily emails, much like ISPs and web hosts. Your email sending process is also private, which helps maintain your company's and customers' data privacy.

However, it also takes valuable time and resources, as you need a specialized team to monitor the server. A private server also becomes vulnerable to Internet connectivity issues and power outages.

On the other hand, using a third-party email service means that more security, more money saved, and much less work for you when it comes to maintaining the server. However, all of these benefits mean you're reliant on others; your server is out of your hands. If you choose a third-party server, choose one you can count on.

How to configure an SMTP server

Configuring a Simple Mail Transfer Protocol server is a quick process. Follow these steps:

  1. Open your email client. It doesn't matter what client you use - it can be Gmail, Microsoft Outlook, Mozilla Thunderbird, or another client altogether.
  2. Go to your client's account settings.
  3. Choose Outgoing Server (SMTP).
  4. Click the Add button to add a new SMTP server.

Each email client also has standard server settings. The Office365 SMTP settings, for example, are server smtp.office365.com, port 587, and STARTTLS encryption. The Gmail SMTP settings are server smtp.gmail.com, port 587, and TLS encryption. Gmail also has the alternative port number 465, which uses SSL encryption for email encryption.

SMTP vendors

If you're looking for a Simple Mail Transfer Protocol vendor to incorporate into your mail system, consider using one of the following vendors.

  • Amazon Simple Email Service
  • Brevo
  • SendLayer
  • PepiPost
  • Elastic Email

These vendors are all recommended for Simple Mail Transfer Protocol services.

Frequently asked questions

What is my SMTP mail server?

It's a computer or a collection of computers that take care of the whole email delivery process - from senders to receivers.

What is an SMTP port?

Put simply, an Simple Mail Transfer Protocol (SMTP) port is a communication endpoint that handles the transmission of email data over SMTP.

Is SMTP a stateful protocol?

Yes, it's stateful, as it exchanges large amounts of data.

What is an SMTP server address?

A path of an email server for outgoing messages. It ends in yourdomain.com.

Is an SMTP server the same as a normal server?

Yes. Technically SMTP server processes and sends data to another server. But the SMTP server's main purpose is to send, relay, and receive email messages.

Is Gmail an SMTP server?

Yes, Gmail uses SMTP to push messages in conjunction with other servers to receive mail.