SMTP: What Is It & How Does It Work?

How SMTP Works?
Yurii Bitko Yurii Bitko 08 june 2021, 15:24 0

SMTP (Simple Mail Transfer Protocol) is a network protocol for transferring e-mail. It is used every time we send an email via web services (Gmail), desktop programs (Outlook, Thunderbird, TheBat), or mailing services.

Gmail, Yahoo, AOL, and other email providers can be compared to your local post office. You visit it, indicate the address on the envelope and give it to the postman.

SMTP is everything that happens in the post office when you send an email. For example, a postman sticks stamps at the post office, checks the parcel’s weight, organizes logistics, and delivers the letter to the addressee.

Here raises the question: if SMTP is so versatile, why can't you send emails directly through it? It is quite possible, except for one thing, which I will talk about later.

In the meantime, here’s some theory.

Theory: How Does SMTP Work

An ordinary user does not need SMTP knowledge; it is enough to use any mailer interface. You use the commands from the mailer, and it sends requests to the recipient's server.

Here is an example of what server communication looks like from the inside (SMTP session):

An example of an SMTP session

$ telnet example.com 25 — we are trying to connect to example.com on port 25, which is used to transfer mail.

Trying example.com...
Connected to example.com.
Escape character is '^]'.

220 mailserver at example.com greets you. Make love not war! — connected successfully.

HELO test.com

250 example.com — we greeted each other with the HELO command, the recipient's server replied with a 250 command, which means that further communication is possible.

MAIL FROM: <test@test.com> — we tell the server the address where the letter is to be sent.

250 2.1.0 Ok — the server replies that it is ready to accept a letter from this addressee (there are situations when the address is included in the blacklist on the recipient's side, so it may cause some errors).

RCPT TO: <user@example.com> — we tell who we want to send the letter to.

250 2.1.5 Ok — the server replies that it is ready to receive a letter for this recipient (if the address does not exist, the server can say something like 550 No such user here).

DATA — we inform the server that we start sending the letter.

354 End data with <CR><LF>.<CR><LF> — the server indicates the form in which it wants to see the end of the letter.

FROM: test@test.com — we start sending the letter along with the technical headers.

TO: user@example.com

SUBJECT: test mail from test subject

test body

. — we indicate that we have completed the letter transmission.

250 2.0.0 Ok: queued as 1CF5FC0AAE — the server replies that it accepted the letter for delivery and assigned it the id 1CF5FC0AAE (in case of non-delivery, the system administrator of the receiving server will be able to find what happened to the letter using this ID).

QUIT — we inform the system that the communication session is over.

221 2.0.0 Bye — the server says goodbye.

Connection closed by foreign host. — indicates that the connection is dropped.

This is an example of the simplest SMTP session. It can be much more complicated if there are multiple recipients or the recipient's server requires authentication and encryption.

What might stop you from learning the SMTP documentation in detail and sending bulk emails through your SMTP solution? So, there is a problem.

Let's consider different methods of sending bulk mailings and evaluate them according to three parameters: improvement necessity (from the developer’s side), the deliverability of letters, and the price.

Free mailbox

  • Improvements from the developers: ⭐️
  • Bulk deliverability: ⭐️
  • Price: Free

Almost every mail provider (Gmail, Yahoo) gives access to the mailbox via SMTP. However, you won't be able to send bulk mailings from free mail.

Advantages:

Mailboxes on Gmail, Yahoo, AOL are free. That’s it.

Disadvantages:

As long as you send a couple of emails, you may be OK with free mail. However, if you have a lot of subscribers, you will face limits on the number of letters.

You won't be able to send more letters. If you try to step over the acceptable threshold, then the mailbox will be blocked, and all letters will get into the "Spam" section.

Mail providers cannot afford spam to be sent from their servers. It worsens their reputation, which is why even quality messages may not reach the "Inbox" section.

Conclusion: not suitable for bulk mailings.

Internet Service Provider Mail

  • Improvements from the developers: ⭐️
  • Bulk deliverability: ⭐️
  • Price: ⭐️

Many ISPs give users mail on their domain. This method is similar to the previous one: the Internet provider’s mail is suitable for personal correspondence, but not for bulk mailings. Emails are sent through the IP addresses of the provider, and the provider cannot allow spam to get through it. Therefore, most of these mailboxes also have a limit on the number of letters per day.

Conclusion: not suitable for bulk mailings.

Hosting

  • Improvements from the developers: ⭐️
  • Bulk deliverability: ⭐️
  • Price: ⭐️

Advantages

You get an email address on the same domain as your website. It’s quite convenient when you have a small online store, and you need to send messages with the order status.

Disadvantages

If you need to send out many emails, you may face limitations and difficulties.

Often, hosting is located on the shared IP addresses of the provider. It means that someone else may be on this IP address and send spam. That’s why your emails may also end up in spam. Providers restrict bulk mailing for hosting owners and require a VPS (virtual server) or a dedicated server purchase, which brings us to the next point.

Conclusion: suitable for bulk mailings, only if you buy a virtual server and configure it.

Own SMTP Solution

  • Improvements from the developers: ⭐️⭐️⭐️
  • Bulk deliverability: ⭐️⭐️⭐️ (if configured correctly)
  • Price: ⭐️⭐️

As we have already mentioned, SMTP encompasses everything about sending and delivering a message to the recipient. Only you are in charge of what exactly to send and how to do it. SMTP is suitable for everything: transactional emails, bulk mailings, or personal correspondence.

Advantages

Ease-of-use. SMTP is a simple protocol: it's easy to test and implement (especially if you've already had an SMTP solution before).

SMTP can be quickly tested since it is a standard protocol. This is obviously an advantage. While using SMTP, such tools as unsubscribe links, templates, and tracking can also work. This information can be reflected in the X-headers of the letter. However, it may require improvements.

Using SMTP requires less knowledge to implement than using the WEB API (on which transactional email services are built). SMTP is well understood and has detailed documentation. Unforeseen circumstances, such as a sudden change in protocol or a change in some methods processes, are minimized.

In order to start an SMTP server, you need to understand how the protocol works and study the set of required commands.

Detailed error report. Using SMTP, you immediately receive a delivery response or delivery failure message. Many services do not provide a detailed response for non-delivery reasons. If the letter did not reach the recipient, a service will display such a reason as a non-existent address or block the message as spam.

The SMTP session will show at which stage the delivery error occurred. If an error occurred during the MAIL FROM data transfer stage (see an example of an SMTP session), then your return address does not correspond to the recipient's server.

Disadvantages

Greylisting. SMTP requires constant communication between the sender and recipient servers. It is not enough to send one request to send a letter. First, the servers must get acquainted, and then the sender must tell who the letter is from and provide the contents of the letter. At each stage, we are waiting for a response from the recipient's server. In case, when it comes to one letter, there are no problems.

However, when you need to send emails in bulk, there is a chance that greylisting will be enabled. It is an anti-spam technology: when the recipient's server deliberately replies to your SMTP server that it is unavailable. In this case, SMTP that sends spam usually stops the sending process. Your SMTP server logic must include knowledge of this behavior. For example, in mailing services, repeated attempts to send are automated. Thus, it is more likely that the letters reach the recipients.

Deep revision. Setting up full-fledged email marketing on your SMTP server takes a lot of work. In order to keep track of openings and clicks from emails, you need special headers or track pixels. You also have to contact the developers every time you need a new tool.

Protocol. Not all ISPs support SMTP. Some do not allow this SMTP to be used to avoid spam.

Conclusion: quite suitable for bulk mailings. However, it needs a deep revision from the developer’s side.

Transactional Mailing Service

  • Improvements from the developers: ⭐️⭐️⭐️
  • Bulk deliverability: ⭐️⭐️⭐️
  • Price: ⭐️⭐️

Transactional mailing services are also based on SMTP. The developers added API methods to it. There are commands which call different functions: sending a letter, unsubscribing from a mailing list, creating a letter template, and getting statistics. In regular SMTP, these things require more effort.

Advantages:

When you need to program something, it's easier just to use the Web API. It works over the HTTP protocol: you can access the API the same way you open websites in a browser.

The thing is that it is not convenient or allowed always to use SMTP. Many ISPs and even hosting providers prohibit it in order to counter spam.

Here is an example of a transactional mailing service. There is a courier who will deliver the letter. You can send mail for yourself, or you can hire a courier. It allows you to personalize your newsletter, use templates, track readings, and click-throughs. It is convenient and saves a lot of time.

The main advantages of this approach are:

  • An additional level of data protection in the form of API keys. You communicate with the service through an API key, which reduces the risk of username and password theft. Scammers will not be able to send spam or conduct phishing attacks on your behalf. This is an additional layer of protection that is not available with direct SMTP.
  • In the case of the Web API, you don't need to communicate with the SMTP server. The service does it for you. You only give the task to send a letter which is actually only one request.
  • Using the Web API makes it easier to send an email and automate the process via your application.
  • Ready-made tools for obtaining statistics.
  • Using the API over HTTP is almost always possible. Firewalls usually do not block the HTTP protocol, unlike SMTP.

Disadvantages:

In order to use the transactional letters service, programmers need to make some improvements to implement sending letters via the Web API service.

Also, APIs are much more subject to change. If SMTP does not change, API methods may update, requiring a code change on your side.

Conclusion: suitable for bulk mailings; there are many ready-made functions that need improvements in the case of SMTP.

Mailing service

  • Improvements from the developers: ⭐️
  • Bulk deliverability: ⭐️⭐️⭐️
  • Price: ⭐️⭐️⭐️

If you imagine that SMTP is a post office, and the transactional letters service is a courier service, then the mailing service is a mail processing department, and you are the head of it.

Advantages:

Thanks to a convenient web interface, a letter editor, a contact manager, you can easily prepare and send a newsletter. In addition, mailing services can analyze mailings, segment recipients by various parameters, conduct split tests, and more.

Every tool is ready for work, and in most cases, you don’t need to involve developers.

Disadvantages:

Among the disadvantages of the mailing service, one can highlight the lower speed of work than transactional letter’s services, since the mailing service processes fewer letters per unit of time. If your base does not have hundreds of thousands of subscribers, and you do not need to deliver emails within a few seconds after sending (which is necessary for transactional emails), then you will not notice the difference.

The data about your subscribers is stored on the servers of the mailing service. If you use a CRM system, you need to integrate it with the contact database in the mailing service.

Conclusion: you can send bulk mailings without additional modifications via the mailing service. Besides, you will rarely address the developers, only when you need to set up complex automation scripts or bind another service via API.

Conclusion

SMTP is a convenient protocol on which most mail sending applications are based. If you want to make your own SMTP server for mass mailings, you have to make a lot of effort: add processing of delivery statuses, convenient email statistics, unsubscribe from mailings, and bypass greylisting.

You can go headlong into this, but it's easier to use a transactional mailing service in which these options are already implemented. You will only need developers to integrate the service into your CRM system.

The second option is mailing services. All the functions are embedded in a user-friendly interface. Also, mailing services can collect letters and subscription forms, work with a contact database, set up automatic chains, and conduct split tests without involving programmers.