Simple Mail Transfer Protocol Explained – What is SMTP and how it Works?

Simple Mail Transfer Protocol Explained – What is SMTP and how it Works?.  It is hard to remember a time when there were no emails – but yes, there was once a time. It is also difficult to imagine a today without email communication. Email communication has become one of the most integral parts of both our personal and professional lives.

Simple Mail Transfer Protocol

It would, therefore, be an understatement to say we all owe a lot to the Simple Mail Transfer Protocol (SMTP). In this article, we will have a detailed look into this integral component of the modern communication method.

What is a Protocol?

In networking terminology, a protocol is a standardized set of rules for formatting and processing data that make it possible for connected devices to communicate with one another.

Although connected devices may use different operating systems, software, and hardware, they can use a common protocol to communicate with one another.

Standardized protocols act as common languages between two connected devices.

For example, a Windows PC can communicate with a Linux machine because they both use the Transmission Control Protocol/Internet Protocol (TCP/IP) to connect to the Internet.

What is SMTP?

SMTP or the Simple Mail Transfer Protocol is an Internet standard communication protocol for electronic mail transmission. It was invented in 1981.

This protocol enables mail servers – and other message transfer agents (MTA) – to send and receive electronic messages. It is the protocol that is used when we send email messages via the Internet, for example.

Many of the email clients we use every day – including the likes of Gmail and Outlook – use SMTP to “push” or send out the messages to their respective recipients.

This protocol is sometimes paired with IMAP and POP3 which handle the retrieval of messages, while SMTP primarily sends messages to a server, to complete the email send-and-receive cycle or process.

SMTP only sends text

A point we need to take into consideration is that SMTP can only transfer text messages. In other words, it can’t be used to send any other formats.

But, it can be used with another protocol that helps it carry and transport images as attachments. This “add-on” protocol is known as Multipurpose Internet Mail Extension (MIME) and encodes all non-text data into text format.

The images are converted back into their original formats once they have arrived at their destinations.

What is an SMTP Port?

An SMTP port is a connected devices’ communication endpoint that has been assigned the task of transferring its email data over the Internet and using SMTP – it is denoted by a number.

When an email is sent out to another domain, the port number is attached to it to let it know which port it should go to for proper delivery.

If we were sending an email to the example.com domain whose IP address was xxx.xxx.xxx.xxx and used SMTP port 587 to receive the emails the “send email to” address would be xxx.xxx.xxx.xxx:587.

What is an SMTP Server?

An SMTP server is a machine that is dedicated to handling the sending, receiving, and relaying of email across a network – be it on a Local Area Network (LAN) or over the Internet.

When users click on the “Send” button to transmit an email, the email client sends a connection and communication request to the SMTP server.

The SMTP server accepts the request, opens a connection, and starts to accept instructions about transferring the email. The information included in the instructions tells the server the sender and recipient’s email addresses as well as the contained message.

Once the details have been confirmed by the Mail Transfer Agent (MTA) the email is relayed to the recipient domain’s SMTP server that passes it on to the recipient’s email client.

Types of SMTP servers

There are two types of SMTP servers:

    • Normal SMTP Servers – these are ordinary SMTP servers that are tasked with relaying emails between the origin and destination of emails.  An example of an SMTP server is hMailServer
    • SMTP Proxy Servers – these are servers that authenticate emails before they are relayed to the recipient. They can be configured to be bi-directional and handle both in-bound and out-bound email authentication.  An example is Nginx Mail Proxy Server.

How does SMTP work? – Real use case examples

SMTP commands are a set of codes that help transmit email messages between servers. Some of the basic SMTP commands include:

    • Hello, HELO, EHLO – a command used to initiate the email sending process. The email client identifies itself to an SMTP server using information like its domain name and IP address.
    • MAIL FROM – this identifies the sender of the email using an email address, starts the transaction, and ensures that the server is ready to accept the email. When ready, the server replies with a 250 OK reply code.
    • RCPT TO, Recipient To – this command addresses the recipient or who the email is being sent to. Again, the server replies with a 250 OK reply code. This loop is repeated for each recipient in the address.
    • DATA – now it is time to transfer the data from client to server. All the content is moved to the server. Once it has received it all, the server replies with a 345 reply code signaling the end of the message, followed by a single dot to indicate end of message. Pending acceptance and readiness for delivery of another 250 OK code. The message is then sent to the recipient.
    • QUIT – once the message has been relayed, the email client sends a QUIT command to terminate the connection with the server, which replies with a 221 code.
    • RESET – this command is sent to the server when the email transaction needs to be terminated. All variables are reset and the whole process can be restarted. It is usually used when there is an error and the process needs to be repeated from scratch.

This back and forth communication between client and server would look something like this:

what is SMTP
How SMTP Works

Common SMTP errors

Just like any other technical process, the email process too can result in an error. The messages can bounce, they can be blocked, and they can simply be rejected in which case the recipient server notifies the clients using SMTP error codes.

There are two common groups of SMTP errors:

    • 4.X.X Persistent Transient Failure – indicate that there’s a temporary failure with the mail server. It can be resolved by repeating the command over and over again although these codes are often used by servers to keep untrusted senders at bay.
    • 5.X.X Permanent Error – indicate that the SMTP connection has been dropped and will continue to be generated until it has come back online.

Advantages of owning an SMTP Server

We have seen that SMTP is an important protocol that supports how we communicate over the Internet. It is an integral part of the office environment and it makes sense that a business has its own SMTP server.

Some good reasons for a business to have its own SMTP server include:

    • Full control over server – a business should have full control over its servers, including its SMTP server; management, monitoring, administration, recovery, security, and backing up of the server are fully controlled by the business.
    • Unlimited email sending and account creation – most third-party SMTP relay services have a limit on the amount of email that can be sent. Of course, clients can buy packages with unlimited sending options but that comes at a price. As many accounts as needed can be created.
    • Email tracking – having a server means the business can keep track of emails; disputes regarding whether or not an email was sent and delivered can be easily resolved by looking at records.
    • Prevents getting blacklisted – a business can protect its reputation and prevent its IP address from getting blacklisted.
    • Verification of emails – businesses can protect themselves from emails sent by spammers, malicious users, and containing malicious content that is sent from unverified addresses.

As we can see, there are many advantages to owning an SMTP server. A business would be well advised to set up and run its own server. The only care that needs to be taken is that it is done by a tech professional.

We can help – contact us and let’s see how we can help with setting up your business’ email system.

Avatar for Liku Zelleke
Liku Zelleke

Liku Zelleke is a technology blogger who has over two decades experience in the IT industry. He hasn’t looked back since the day, years ago, when he discovered he could combine that experience with his other passion: writing. Today, he writes on topics related to network configuration, optimization, and security for Cloud Infrastructure Services.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x