What is an SMTP Server?

Is it hard to send an email? From a user’s perspective, everything looks quite simple. Under the hood, however, there is a complex system that drives emails from the sender to the recipient. When you click a button to send an email, your email client connects to the mail server. Servers are computers that handle specific services. A mail or email server is meant for dealing with emails. At the same time, we can break down email servers into two categories: outgoing and incoming. Today, we’re talking about a concept related to an outgoing mail server, known as an SMTP server.

What is an SMTP server?

An SMTP server is a computer or an app that is responsible for sending emails. It functions following the Simple Mail Transfer Protocol (SMTP). An SMTP server receives emails from the email client. Then it passes them on to another SMTP server and relays them to the incoming mail server.

What is the difference between an SMTP server and an IMAP/POP3 server?

SMTP is an email sending protocol, whereas IMAP4 and POP3 are protocols to receive emails. Therefore, an incoming mail server may use one of those protocols for email delivery. Here is how they work:

IMAP workflow

  • The email client connects to the server
  • The recipient can see the headers of all emails on the server
  • The email client downloads a chosen email on demand

POP3 workflow

  • The email client connects to the server
  • The email client retrieves emails
  • The server deletes the stored emails
  • The email client disconnects from the server

The main difference between these protocols is that IMAP servers always store copies of emails, while POP3 servers delete them once they are retrieved. For more on the Difference Between IMAP, POP3, and SMTP Email Protocols, read our blog post.

How an SMTP server works

Take a look at the basic steps of email sending and what role the SMTP server plays.

A mail user agent (MUA), which can be your email client or an app, connects to the SMTP server of your domain (for example, smtp.mailtrap.io). This is called an SMTP handshake. The connection is carried out via an SMTP port, which is normally 25. But there are other options you can learn in our blog post about SMTP ports. Once connected, the SMTP session begins.

The client submits the sender’s and recipient’s email addresses, as well as the email body and attachments, to the server.

The SMTP server, or more precisely the mail transfer agent (MTA), checks whether the domain name of the recipient and the sender is the same. If it is, the email goes directly to the recipient’s POP3 or IMAP server. If the domains are different, the SMTP server has to communicate with the Domain Name Server (DNS).

The DNS provides the recipient’s IP address.

The sender’s SMTP server connects to the recipient’s SMTP server and relays the email. If the recipient’s server is not available (down or busy), the email will be put into an SMTP queue. This is a buffer where the emails are stored before they hit the endpoint. For more on this, read What is an email queue? Alternatively, the email can be dropped to a backup server.

The recipient’s SMTP server verifies the incoming email. If the domain and user name has been recognized, the server forwards the email to the POP3 or IMAP server.

To learn about what is an SMTP server address and what is a fake SMTP server check out this Mailtrap article.