All about SMTP

content ai about smtp
A
Abhijeet Chattarjee

Email Design Specialist & Template Developer

 
August 12, 2022 8 min read

Emails are the most common yet powerful way of communication. The number of e-mails sent and received globally is increasing each year. In 2021, there were an estimated 319.6 billion e-mails sent and received daily globally around the world and this figure is projected to increase to 376.4 billion daily e-mails by 2025. (How Many Emails Are Sent Per Day in 2025? - TechJury) Have you ever wondered how your emails go from you to your recipients?

Just opposite to how simple and easy the email sending process is, there’s a complex process behind the scenes to get your emails delivered. The most common protocol for sending emails is smtp. (What Is SMTP? - SMTP Server Explained - AWS)

What is SMTP?

smtp, which stands for Simple Mail Transfer Protocol, is an email protocol used by mail servers for sending email messages from sender’s email account to receiver’s email account via the internet.

Email protocols are a standard method or set of rules for information exchange, and smtp is one of the most common ones alongside Post Office Protocol 3 (POP3) and Internet Message Access Protocol (IMAP). (What Are Email Protocols - POP3, SMTP and IMAP - SiteGround) POP and IMAP protocols are for sending and receiving emails but smtp is the only dedicated protocol for sending emails.

What is an SMTP server?

An smtp server is a computer or an application running smtp that is responsible for sending emails. An smtp server receives emails from the email client and passes them to another smtp server for relaying. Specifically, an smtp server handles the sending, receiving, and relaying of email. It's important to distinguish this from incoming mail servers which typically use POP3 or IMAP. smtp servers will also have their own dedicated address or set of addresses that will be determined by the client using the server.

free_smtp_server.png

What is an SMTP relay?

smtp mail relay is simply a process of transferring/relaying an email from one server to another server for the delivery. Let’s understand this from an example. You are company ‘x’ who wants to send an email to an employee of company ‘Y’. To do this, you will connect to your company x’s smtp server. Your smtp server connects and delivers your email to company y’s server. The process of accepting an email from one server to another server is “relaying.”

Even when sending an email to someone within your own company (meaning the same domain), there's still a server-to-server transfer involved. Your email client sends it to your company's outgoing smtp server, which then sends it to the recipient's mail server. This server-to-server transfer is still considered relaying.

How does SMTP work?

To better understand the smtp working, we will go through the sending process, the individual rules and commands used in smtp and also the errors you may get. This is going to be bit technical.

smtp is based on end-to-end message delivery and the first step is the connection establishment for communication between the mail sender and the mail receiver is required. The smtp connection is built on The Transmission Control Protocol (TCP). When the user hits the ‘send email’, the email client opens an smtp connection (TCP based connection) to the server. This connection typically uses port 25 (unencrypted), port 587 (TLS encrypted, recommended for submission), or port 465 (SSL encrypted, older standard). The client and server then perform a TCP handshake to establish a reliable connection before any smtp commands are exchanged. The mail sender sends the data in form of command strings over this channel. The smtp client uses commands to tell the server what to do and the data to be transfer like sender’s email, recipient’s emails, and content.

After the initial commands, the Mail Transfer Agent (MTA) starts working on the data. The MTA first checks the email domain. If the domain is the same, it might be delivered directly. For different domains, the MTA uses the Domain Name System (DNS) to find the recipient's mail server. It queries DNS for the Mail Exchanger (MX) records associated with the recipient's domain. These MX records specify which mail servers are responsible for accepting email for that domain and their priority. The MTA then connects to the appropriate recipient mail server to deliver the email.

Sending Mail server.png

Usually, an smtp email transaction follows several commands or reply sequences that power the transmission of email messages between servers. Let’s check them out.

HELO/EHLO

It is the command to start the entire email sending process. It begins the communication and tells the email server that the client-server wants to start the mail transaction. The client mentions its domain/IP address after this command.

Example: HELO mailazy.com or EHLO mailazy.com

EHLO is an alternative to HELO for servers that support ESMTP (Extended SMTP) or smtp service extensions. These extensions offer additional features beyond basic smtp, such as authentication, encryption (like STARTTLS), and more.

MAIL FROM

This command specifies the e-mail address of the sender. It lays down the bounce/return address, defining the return or reverse paths. This tells the smtp server that a new transaction is about to start and makes the server reset all its state tables and buffers etc. to accept the email address. Once accepted, it will reply with a 250 OK reply code.

Example: MAIL FROM [email protected]

RCPT command

This command specifies the e-mail address of the recipient. It sends after receiving 250 OK and is used to identify the destination mailbox. The sender’s envelope contains the addresses of the recipients and can be repeated multiple times for an email message in order to deliver a single e-mail message to multiple recipients.

Example: RCPT TO [email protected]

DATA

This triggers the transfer of data between the client and the server. It shows where the content of the message starts, as opposed to its envelope. An empty line separates the message header and body in the message’s text.

DATA is a single command that initiates a multi-step exchange for message content transfer.

  • First, the server acknowledges the message and replies with its readiness to take the message. Here, the server will respond with a 354 Intermediate status code, indicating it's ready for the message content.
  • Then, after completing the end-of-data sequence (usually a line containing only a period .), it either accepts or rejects the entire message. If accepted and ready for delivery, the server sends a 250 OK code.

The negative responses can further be permanent (5xx codes) or transient (4xx codes).

If a server sends ‘reject,’ then it is a permanent failure, and the client needs to send a bounce message to the respective server.

Example:

DATA
354 Start mail input; end with <CRLF>.<CRLF>
Date: Fri, 13 Jun 2022 00:01:00 +0000
From: [email protected]
Subject: How SMTP works
To: [email protected]
Message-ID: <[email protected]>

This is the body of the email message. It can span multiple lines. . 250 OK: queued as 12345

QUIT

When the email has been sent, the client sends the QUIT command to the server, severing the connection. If it has been successfully closed, the server will reply with a 221 code.

Example: QUIT

NOOP

This command is used to check whether the server can respond. It's often used to keep a connection alive or to check the server's status.

Example: NOOP Server Response: 250 OK

RSET

This command resets the smtp connection to the initial state. It erases all the buffers and state tables. This command is sent to the server when the mail transaction needs to be aborted. It doesn’t close the connection, but it does reset everything and remove all previous data about the email and the parties involved.

Example: RSET Server Response: 250 OK

Understanding SMTP error codes

The smtp server are not always response positive and may return a particular error message.

We can divide smtp error messages in two groups.

  • Transient Failure: These error codes start with the number “4” followed by two other numbers. They typically mean that there’s a temporary failure with the mail server and your email is not delivered yet. It's often worth retrying later.
  • Permanent Error: These error codes begin with the number “5” and are followed by two numbers. They typically signify that the smtp connection has dropped for a reason that won't change. If you try to resend the email, it will likely still result in the same error.

We have added a detailed article on smtp error codes. You can refer to this from here.

Glossary and Terminology related to SMTP

Bounce: An email message that is not delivered is said to have bounced. There are two types of bounce - hard bounce and soft bounce.

Delivered Email: The email is delivered to the recipient’s email address.

Email Address: The combination of a unique user name and a sender domain ([email protected]).

Email Domain: Aka Domain. The right side portion of the email address after ‘@’ sign. For example, In the email address [email protected]. The Domain is mailazy.com

Hard Bounce: A delivery failure for a permanent reason.

IP Address: A unique number assigned to each device connected to the Internet. An IP address can be dynamic or static. Dynamic means it changes each time an email message or campaign goes out (Email sent out from an IP pool), Static means it does not change. Static IP addresses are considered best for sending emails because of a maintained reputation. A good IP reputation is crucial for email deliverability, as it signals to receiving mail servers that your emails are legitimate and not spam, increasing the chances of them reaching the inbox.

IMAP: Internet Message Access Protocol, a standard protocol for accessing email from a server.

POP (Post Office Protocol): Protocol to send or receive messages from an email server.

Queue: For email, a queue is where email messages wait to be processed by the recipient’s mail server.

Server: In the context of email, a server can refer to several things:

  • Mail Transfer Agent (MTA): Responsible for sending and relaying emails between mail servers.
  • Mail Delivery Agent (MDA): Receives emails from the MTA and places them in the recipient's mailbox.
  • Mail Access Server: Allows users to retrieve emails using protocols like POP3 or IMAP.

SMTP: Simple Mail Transfer Protocol, the most common protocol for sending email messages between email servers.

Soft Bounce: Email sent to an active email address but is not delivered. Often, the problem is temporary.

Spam: Refers to unsolicited email also known as "junk". It can be annoying, clog inboxes, and sometimes be used for malicious purposes like phishing. Mail servers use spam filters to try and block unwanted emails.

Transactional Email: An email sent to an individual recipient for a specific action performed by that person.

A
Abhijeet Chattarjee

Email Design Specialist & Template Developer

 

A seasoned Product Marketing expert with extensive experience in product management and marketing strategies. Skilled in driving go-to-market plans, customer engagement, and cross-functional collaboration, they excel at aligning product development with market needs to deliver growth. Passionate about creating compelling product narratives, they combine data-driven insights with innovative solutions to boost brand visibility and customer satisfaction.

Related Articles

What Does it Mean to Receive an Email from a Mailing List?
mailing list

What Does it Mean to Receive an Email from a Mailing List?

Discover what receiving a mailing list email really means for SaaS providers. Learn about deliverability, compliance, and how email infrastructure impacts your business.

By Marco Giuliani January 21, 2026 6 min read
common.read_full_article
The Comprehensive Guide to Email Opt-Outs
email opt-outs

The Comprehensive Guide to Email Opt-Outs

Master email opt-outs with our guide. Learn about can-spam compliance, reducing unsubscribe rates, and using email apis for better deliverability.

By Rahul Yadav January 19, 2026 6 min read
common.read_full_article
What is the Purpose of Email Deliverability in the Sales Funnel?
email deliverability

What is the Purpose of Email Deliverability in the Sales Funnel?

Learn why email deliverability is the secret sauce for SaaS sales funnels. Discover how to improve inbox rates and boost B2B conversion through better email infrastructure.

By Rahul Yadav January 16, 2026 7 min read
common.read_full_article
Is Email Spoofing Against the Law?
email spoofing law

Is Email Spoofing Against the Law?

Discover if email spoofing is illegal under US law. Learn about CAN-SPAM, the CFAA, and how to protect your b2b saas email deliverability from bad actors.

By Rahul Yadav January 14, 2026 7 min read
common.read_full_article