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.
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.
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:
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.
Take a look at the basic steps of email sending and what role the SMTP server plays.
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.
An SMTP server has a web address to communicate with other servers and clients on the Internet. Usually, it looks like
mail. plus the domain name. For example,
mail.gmx.net. If you’ve set up a local SMTP server, you can use its IP address, let’s say,
127.0.0.1, instead of the web address.
Users of shared email services can find information about the SMTP server address by looking up the MX records of the domain.
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:
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 name the SMTP server an MTA or even an MSA, this won’t be a mistake. The difference lies in the nomenclature you use.
SMTP relay is the process of transferring emails between SMTP servers (or MTAs if you will). 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 Mailgun 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 thing.
In the article Best Free SMTP Servers, we introduced a list of cloud-based options that most startups and projects opt for. These include Gmail, Amazon SES, Elastic Email, and others. The main benefit of using one of those is that you don’t have to build and maintain the whole email environment. This means you save your resources. If you want to know how to configure Gmail SMTP for sending bulks of emails, check this tutorial.
A local SMTP server might be an option as well. 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 deliverability. If you want to know how to set up a local SMTP server, check out this blog post.
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 addresses unless you want your test emails to hit the inboxes of real customers. But using dummy email for testing just doesn’t work. That’s why a fake SMTP server comes into play!
Mailtrap.io represents a cloud-based email testing service with a fake SMTP server under the hood. You send test emails from your app and Mailtrap catches and puts them into a virtual inbox. You can be sure that none of the emails will get to a real user. Additionally, you can preview the content of the emails, check them for spam and much more. For more on the available features, read the Mailtrap Getting Started Guide.
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 to choose between cloud-based and local fake SMTP options in the dedicated blog post.
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:
|Web API||SMTP Relay Server|
- Fast email delivery
- Optimized security
- Analytics capabilities
- Easy to set up
- Simpler troubleshooting
- Complex solution that requires coding skills
- No unique specification, so each email service provider implements its own solution
- Slow performance for bulk emails
- Changing deliverability of emails
- Possible blockage of port 25
Pick an SMTP server if:
Pick Web API if:
For more about differences between SMTP relay server and HTTP API, read our blog post.
Let’s say you’ve checked the email sending of your app and it’s alright. We hope that Mailtrap helped you with that :). But when you started using a real SMTP server for sending emails, they were not delivered. The following checklist will help you detect what may be wrong:
An SMTP server is your digital postman, which either delivers your emails right to the recipients’ mailbox or hands them over to other postmen out of your domain. Keep in mind that SMTP servers deal with outgoing mail only. For incoming emails, you’ll need another type of mail server – IMAP or POP3. We’ll talk about them in one of our next blog posts. Stay tuned with Mailtrap!
That's it! Thanks for reading our article that was originally published on Mailtrap Blog: https://mailtrap.io/blog/what-is-smtp-server/