All You Need to Know about SMTP Server 

On January 27, 2024
9min read
Zakhar Yung Technical Content Writer @Mailtrap
This is a cover image for an article on the ins and outs of SMTP servers

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. An 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 email server and relays them to the incoming mail server.

How does an SMTP server work? 

Take a look at the basic steps of the email-sending route 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, to start the SMTP connection. This is called an SMTP handshake. The connection is carried out via an SMTP port, which is normally 25. However, other ports, such as 465, 587, and 2525, could also be used in different cases. You can learn more about them 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 our blog post about email queuing. 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 have been recognized, the server forwards the email to the receiving servers, POP3 or IMAP server.
This is an image showing an illustration of how an SMTP server works without relay

Is an SMTP server secure? 

Surprisingly enough, the SMTP server isn’t inherently secure. It doesn’t have any encryption or security mechanisms built into it. This makes it vulnerable to spoofing, spamming, or data leakage. To avoid all those unfortunate events, email providers have added security layers to the infrastructure. 

The first mechanism they incorporated was the Secure Sockets Layer (SSL) but it had significant security flaws. As a result, the Internet Engineering Task Force (IETF) deprecated its final version, SSL 3.0 in 2015 by enforcing RFC 7568. 

4 years after SSL’s creation, another security standard, Transport Security Layer (TLS), was introduced to the public. Initially, it wasn’t perfect either, yet it was improved throughout the years. As of 2022, the TLS 1.3 version is considered to be the safest protocol for email encryption

All of that is great, but at what point of the SMTP connection does TLS enter the game? By default, most email clients initiate a TLS connection during the handshake. They do so by using the SMTP command STARTTLS, which initiates the switch to an encrypted connection. To learn more, check out our blog post about SMTP security

What is SMTP authentication

SMTP authentication or SMTP AUTH is the mechanism used to secure the outgoing email server. It’s the service provided by the Extended Simple Mail Transfer Protocol (ESMTP) which adds new functionalities to the SMTP protocol, including authentication. 

SMTP AUTH ‘demands’ that the sender is authorized to use the server to send emails. It makes it harder to impersonate real users, protecting them from spoofers and spammers. 

SMTP AUTH leverages the SASL mechanism for authentication, which specifies the level of security and login methods. Mechanisms such as PLAIN, LOGIN, and CRAM-MD5 are commonly used in that process. To dive deeper into SMTP authentication, check out our dedicated guide. 

Should you use local or cloud-based SMTP servers

Your own SMTP server 

Setting up your own SMTP server might be an option if you want to send bulk emails. It imposes no limit on how many emails you send per hour/day and ensures control of all your outgoing mail. 

However, this comes with a drawback as the bounce rate can increase by 20-30%, which is a major consideration for the deliverability of transactional or email marketing campaigns. If you want to know all the ins and outs of setting up your own SMTP server, read this blog post.

3rd party email sending API

In our guide about the best free SMTP servers, we introduced a list of cloud-based 3rd party email APIs that most startups and projects opt for. These are SMTP relay services that include Gmail, Amazon SES, Elastic Email, Mailtrap, and others. 

The main benefit of using SMTP service providers instead of a local SMTP sever is that you don’t have to build and maintain the whole email infrastructure on your own. This means that you save your resources. 

However, it’s important to pick out a reliable option such as Mailtrap Email Sending. It’s an end-to-end solution that can safely deliver email messages to the recipients’ inboxes. 

It includes a bunch of useful features, such as actionable analytics, SDKs for a range of programming languages, on-time email delivery, smooth and secure setup, and more. The mentioned analytics can be used to track and control the deliverability of all your outbound emails. 

This is an image showing the Mailtrap Email Sending Statistics Overview feature

What’s most important is that Mailtrap Email Sending makes it dead easy to use its SMTP service or email API. Once you verify your domain with SPF, DKIM, and DMARC authentication protocols, you’ll immediately see SMTP and email API credentials for the transactional and bulk email-sending stream.

Mailtrap Email Sending’s SMTP server leverages PLAIN and LOGIN authentication mechanisms and requires STARTTLS encryption. 

This is an image showing the Mailtrap bulk and transactional email-sending stream

Now that you know what an SMTP server is and how it works, let’s dig deeper and answer the other questions you may have.

SMTP relay server or HTTP API – which one is better and when?

A mail user agent (the client) sends emails to the server via SMTP. It is a platform-agnostic protocol widely used for sending emails. At the same time, you can send emails from your app using a web-specific protocol – HTTP. In this case, there are no client-server or server-server back-and-forths. Your app sends HTTP requests to a third-party service that performs email sending. This way of mail delivery is known as HTTP API or Web API.

We can’t claim that Web APIs exceed the service of SMTP relay servers. Each option has its pros and cons.

This is an image showing the pros and cons of web API and SMTP relay server

Pick an SMTP server if:

  • you prefer simplicity for basic tasks 
  • you need integrability with your CRM system or mail client for managing customer relationships
  • you’re looking for a reliable and sustainable solution

Pick a web API if:

  • you deal with bulk emails
  • you need greater functionality
  • you don’t mind tinkering with the code

For more about the differences between SMTP relay server and HTTP API, read our blog post. 

What is an SMTP server address?

An SMTP server has a web address to communicate with other servers and clients on the Internet. Usually, it looks like smtp. or mail. plus the domain name. Here are some examples: 

Email service provider SMTP settings and addresses
Microsoft 365 and OutlookServer:
Port: 587
Encryption: STARTTLS
Gmail Server: 
Port: 587 or 465
Encryption: SSL, TLS or STARTTLS
Port: 587
Encryption: N/A
Port: 587 or 465
Encryption: SSL or TLS
iCloud Mail Server:
Port: 587
Encryption: SSL, TLS or STARTTLS

If you’ve set up your own SMTP server, you can use its IP address, for example,, instead of the web address. 

Users of shared email services can find information about the SMTP server name and address by looking up the MX records of the domain.

Is an SMTP server and an SMTP relay the same?

SMTP relay is the process of transferring emails between SMTP servers (or MTAs if you will). A relay happens if the sender and the recipient come from different domains. In practice, however, the term SMTP relay often refers to SMTP servers that enable relaying. Email providers like Mailtrap Email Sending offer such relay servers for bulk email and transactional email sending. In this context, we can say that an SMTP server and an SMTP relay are the same things.

What is a fake SMTP server

  • A real SMTP server accepts emails from the client and sends them to the incoming mail server. 
  • A fake SMTP server accepts emails from the client and emulates sending without actual delivery. 

Why would I need a fake one then? – For testing email sending, of course!

At a certain stage of your project, you’ll need to send a couple of test emails from your app or website. You can do this using a real SMTP server. In this case, you would have to tinker around with dummy email accounts, a.k.a. create hundreds of email addresses that will disappear in a few hours. 

If we’re being completely honest, dummy emails aren’t the best solution for testing. They require too many resources, have limited design testing capabilities, and contain the risk of spamming real users. That’s where a fake SMTP server comes into play!

In addition to Email Sending, the Mailtrap Email Delivery Platform consists of Email Testing, a cloud-based testing solution that captures outgoing SMTP traffic. 

With Mailtrap Email Testing, the test emails you send from your app will be trapped using a fake SMTP server and put into a virtual inbox. You can be confident that none of the emails will get to your users. Unlike dummy emails, Email Testing allows for QA automation and eliminates most of the manual labor. 

This is an image showing the HTML preview feature in Mailtrap Email Testing

Additionally, you can preview the emails, check them for spam and your sender domain/IP for blacklist presence, inspect the HTML/CSS, and do more. 

This is an image showing the HTML Check feature in Mailtrap Email Testing

You may also consider setting up a local fake SMTP server like MailHog or MailCatcher or even a desktop app, for example, FakeSMTP or DevNull SMTP. We described the reasons for choosing between cloud or local fake SMTP options in the dedicated blog post. 

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 for receiving emails. Therefore, an incoming mail server may use one of those protocols for email delivery. Here is how they work:

IMAP workflowPOP3 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
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 differences between inbound and outgoing servers, check our IMAP vs POP3 vs SMTP blog post. 

How does an MTA differ from an SMTP server?

It is common practice to use the term “mail transfer agent ” instead of “SMTP server”. But aren’t these notions different? An MTA is software installed on the SMTP server. Generally, an MTA receives emails from an MUA and forwards them to:

  • a mail delivery agent (MDA), if the sender and the recipient have the same domain, or
  • another MTA (SMTP server) 

In some cases, there could also be a mail submission agent (MSA) between the MUA and MTA. However, many MTAs carry out the MSA function, that’s why the mention of mail submission agents is often omitted. The most used MTAs are Postfix, Sendmail, and Exim.

So, if you call the SMTP server an MTA or even an MSA, this won’t be a mistake. The difference lies in the nomenclature you use.

SMTP server troubleshooting checklist

Let’s say you’ve checked the email sending of your app, and it’s alright. We hope that the Mailtrap Email Delivery Platform helped you with that :). But when you started using a real SMTP server to send emails, they were not delivered. The following checklist will help you detect what may be wrong:

  • check the Internet connection
  • check the SMTP server configuration (server name, port, username, password)
  • try different SMTP ports
  • test the SMTP server connection. For this, you can either use an online service like MXToolbox or perform a manual telnet session. Read our blog post about testing SMTP server to learn how to do this. You may also need to know SMTP commands and response codes for troubleshooting.

Wrapping up 

That’s everything we wanted to cover in this guide about SMTP servers. We’ve touched upon all the frequently asked questions, including what an SMTP server is, how it works, how it compares to other SMTP servers, and how to troubleshoot the errors. We also discussed 3rd party SMTP relays and fake SMTP servers for testing. 

To leverage the fake SMTP servers and then send emails through a cloud-based SMTP, we recommend using the Mailtrap Email Delivery Platform. It’s a single solution for all your SMTP needs. 

For an in-depth look into the different aspects of the SMTP server, check out the blog posts we’ve recommended above. 

If there are any other topics you’d like us to cover, then let us know on Twitter. 

Article by Zakhar Yung Technical Content Writer @Mailtrap