Join us
@sofiatarhonska ă» Oct 24,2022 ă» 8 min read ă» 765 views ă» Originally posted on mailtrap.io
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:
IMAP workflow
POP3 workflow
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 smtp.
or mail.
plus the domain name. For example, smtp.gmail.com
or 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 | |
Pros |
- Fast email delivery - Optimized security - Analytics capabilities |
- Easy to set up - Platform-independent - Simpler troubleshooting |
Cons |
- Complex solution that requires coding skills - Modifiability - 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/
Join other developers and claim your FAUN account now!
Influence
Total Hits
Posts
Only registered users can post comments. Please, login or signup.