Email Protocols Explained: IMAP vs POP3 vs SMTP [2024]

  • 5,000
  • Tác giả: admin
  • Ngày đăng:
  • Lượt xem: 5
  • Tình trạng: Còn hàng

Three main parties are involved in transferring an electronic message: the sender, the recipient, and the tin nhắn server. The tin nhắn goes from the sender to tát the mail server, which then lets the recipient get the message. 

What is the role of tin nhắn protocols here? They establish connections between transferring parties. So, one protocol is needed to tát send, and one – to tát receive. 

Today, we’ll review and compare the three most commonly used tin nhắn protocols – IMAP vs POP3 vs SMTP – and help you choose the right option for your needs. 

What is an tin nhắn protocol? 

An tin nhắn protocol is a combination of principles and rules that make it possible to tát transfer messages between different servers, machines, and tin nhắn clients. It creates standards that messages should follow to tát reach the recipients in their original state. 

For example, when you send an tin nhắn from Gmail client to tát someone with Outlook address, you expect all the attachments and toàn thân elements to tát be present when they view your tin nhắn. This is true whether they use Apple Mail, Microsoft Outlook, or Thunderbird clients to tát access their inbox. 

Email protocols also determine how messages should be sent and accessed, what format they should have, and what structure should the connection follow. 

SMTP – a standard protocol to tát send emails

What is SMTP?

Simple Mail Transfer Protocol (SMTP) establishes how the message gets from the sender to tát the tin nhắn server. Also, it is used by a mail transfer agent (MTA) to tát deliver emails between servers. This process is called mail relaying (or SMTP relay). 

SMTP is only meant for sending tin nhắn messages. 

How emails are sent via SMTP

How SMTP works

SMTP workflow consists of commands sent by the SMTP client and corresponding replies by the SMTP server. 

Default SMTP commands are text-based, such as HELO, MAIL FROM, and others. Sometimes you might encounter extended SMTP (ESMTP) commands such as EHLO, STARTTLS, etc. 

Replies are represented by numeric completion codes (for example, 220, 250, 354, and so sánh on). For more on SMTP commands and response codes, read our dedicated blog post.

Any SMTP conversation consists of three stages:

  • SMTP handshake – The SMTP client establishes a TCP connection with the SMTP server. Once the server replies with 250, the handshaking starts. The stage ends when the server confirms the recipient’s address.
  • Email transfer – Code 354, as a response to tát the DATA command, launches the transfer of the tin nhắn. Once the server gets a final dot, the message is transferred. 
  • Termination – Client and server say goodbye to tát each other using the command QUIT and code 221, respectively. 

Let’s take a look at the interaction between the SMTP client and server through a simple tin nhắn delivery example:

Command or ResponseWhat it means
Client: HELO client.rocket.comorEHLO client.rocket.comIdentifies itself and initiates the SMTP conversation. The domain name name or IP address is usually sent as an argument together with the command. EHLO is an alternative command to tát start the conversation. It identifies that the client uses the ESMTP protocol.
Server:250OK or completed
Client: MAIL FROM:Says that a new mail transaction is starting and specifies the sender
Server:250OK or completed
Client: RCPT TO:Specifies the recipient. (For multiple recipients, the command will be repeated for each recipient’s address)
Server:250OK or completed
Client: DATAInitiates the transfer of the tin nhắn contents including toàn thân text, attachments, and so sánh on.
Server:354Lets the client start the nội dung transfer
Client: Date: Wed, 24 July 2019 16:03:23Date
Client: From: [email protected]From header
Client: Subject: How SMTP worksSubject line
Client: To: [email protected]To header
Client: Empty line
Client: Hope, it’s not boring:)Body text
Client: .Once the message contents have been transferred, a single dot must be sent in a line to tát terminate.
Server:250OK or completed
Client: QUITRequest to tát terminate the SMTP conversation
Server:221Closes transmission channel

SMTP ports

  • 25

This is a standard port for relaying messages between tin nhắn servers. Cloud hosting providers and many tin nhắn clients (Gmail, Microsoft Outlook, Mozilla Thunderbird, etc.) block port 25 to tát prevent spam. They usually prioritize secure connections lượt thích 587 or 465.

  • 465

465 is not an RFC-compliant port. It was meant for the SMTPS encryption and authentication wrapper over SMTP. IANA registered 465 as an SMTP port, but it has never been recognized as an official SMTP transmission or submission channel. 

Later on, port 465 became obsolete and was revoked in favor of STARTTLS wrapper over SMTP. Nevertheless, today many servers still use SMTPS and maintain 465.

  • 587

A mặc định SMTP port 587 is the option to tát submit an tin nhắn for routing. TLS encryption ensures the secure submission of the tin nhắn. Almost all mail servers tư vấn 587.

  • 2525

It is not an official SMTP port, but almost any tin nhắn service provider supports it. 2525 is secured similarly to tát 587 and is often used in lieu of it. So, if the use of the mặc định SMTP port causes some trouble, try 2525.

For more on this, read our blog post about SMTP ports.

And for a deeper dive into the differences between SMTP and a protocol such as IMAP, kiểm tra out this video:

IMAP4 and POP3 – protocols to tát receive emails

Once the tin nhắn knocks at the mail server’s door, either IMAP or POP3 will be used to tát retrieve it. Both of these servers are message accessing agents (MAAs). 

What is IMAP?

Internet Message Access Protocol (IMAP) is a communication standard for accessing emails. Today, its fourth version is in use, hence the name IMAP4. 

IMAP stores emails on a remote server and downloads them on demand when the recipient opens them. So, the IMAP protocol gets access to tát the tin nhắn from any device or location if authorized. This allows for tin nhắn synchronization, which is why IMAP is the go-to option for most tin nhắn service providers. 

How IMAP works

How IMAP works

Here is the basic flow of the IMAP client/server interaction: 

  • A recipient’s mail client connects to tát the server the message is stored on
  • The recipient can see the message headers of all the emails on the server
  • If the recipient chooses a particular message to tát read, IMAP downloads it on demand

Under the hood, a primitive IMAP connection may look as follows:

Client commandDescription
LOGINOpens the IMAP connection
LISTCREATERENAME and other commandsCommands that allow you to tát manage mailbox 
SELECTDefines the current mailbox and opens an IMAP session
LISTDOWNLOADDELETE and other commandsCommands that allow you to tát manage messages
CLOSECloses the IMAP session. If you want to tát open a new session, you can tự this by setting up another current mailbox. Once the new session is opened, the IMAP server permanently updates the messages according to tát the previous session. 
LOGOUTCloses the IMAP connection

Here you’ll find a full selection of client commands.

Darn! We forgot about the IMAP server responses. There are three forms of them:

  • Status Responses (OK, NO, BAD, PREAUTH, and BYE)

They may include a response code lượt thích ALERT or CAPABILITY.  A response code gives additional information beyond the status response condition. 

  • Server Data

These responses include Server and Mailbox Status (CAPABILITY, LIST, etc.), Mailbox Size (EXISTS and RECENT), and Message Status (EXPUNGE and FETCH)

  • Command Continuation Request

This response confirms that the server is ready to tát accept the continuation of the client’s command. It is represented by a “+” token.

IMAP ports

  • 143 – A mặc định IMAP port without encryption
  • 993 – A secured SSL/TLS port used by most tin nhắn service providers. It is often called IMAPS. 

What is POP3?

Post Office Protocol 3 is a simpler way to tát access mailboxes. We use its third version – that’s why it’s called POP3. Users love this protocol for its low dependency on Internet connections. 

POP3 protocol downloads emails from the server to tát the local computer, so sánh you can read them even offline. The server deletes messages once they are retrieved. This is the mặc định and common setting, but there is the option to tát enforce a site policy regarding tin nhắn retention on the server. 

At the same time, even if the POP3 client contains configuration options to tát store tin nhắn, the server won’t tư vấn such an action. 

How POP3 works

How POP3 works

POP3 connection consists of four steps: 

  • The client connects to tát the server (AUTHORIZATION State)
  • The client retrieves new emails (TRANSACTION State)
  • The server deletes the stored messages (UPDATE State)
  • The client disconnects from the server

Let’s take a look under the hood of a POP3 session as well. 

Command or ResponseWhat it means
Server:The server is waiting for the connection on TCP/IP port 110
Client: The client establishes a TCP connection. 
Server:+OK POP3 server ready If everything is OK, the server’s response will be consistent. Otherwise, it will show -ERR
Client: APOP mrose c4c9334bac560ecc979e58001b3e22fbProvides origin identification and trả lời protection for the session. mrose is the name parameter and c4c9334bac560ecc979e58001b3e22fb is the digest parameter. They identify a mailbox and an MD5 digest string
Server:+OK If everything is OK, the server’s response will be consistent. Otherwise, it will show -ERR
Client: STATNow, the session enters the TRANSACTION state. STAT command asks how many messages are currently in the mailbox and their size in octets
Server:+OK 1 334Maildrop has one message of 334 octets
Client: DELE 1Deletes the message
Server:+OK message 1 deletedIf everything is OK, the server’s response will be consistent. Otherwise, it will show -ERR
Client: QUITOnce the session is over, the client logs off via QUIT command
Server:+OK dewey POP3 server signing off (maildrop empty)If everything is OK, the server’s response will be consistent. Otherwise, it will show -ERR
Client: The client closes the TCP connection. 
Server:The server is waiting for connection on TCP port 110

We used only two commands (DELE and STAT) that are valid in the TRANSACTION state. You can find more options here. 

As for POP3 responses, they contain a status indicator (+OK or -ERR) and a từ khóa that may be enhanced with additional information (for example, -ERR no such message, only 2 messages in maildrop).

POP3 ports

  • 110 – A mặc định POP3 port without encryption
  • 995 – A secured SSL/TLS port that is often referred to tát as POP3S. 

IMAP or POP3 – which protocol should I choose? 

At first, we were considering making a table with a comparison of the pros and cons of IMAP and POP3. But this idea proved untenable since different users would have different demands in terms of the tin nhắn protocol standards. So, we decided to tát mix it up this way instead.

Pick IMAP4 if: 

  • you need access to tát mail from different devices 
  • you need to tát organize your mail in folders or some sort of hierarchy
  • you have unlimited server storage space
  • you have a constant and stable Internet connection
  • you need fast access to tát your mail

Pick POP3 if: 

  • your mạng internet connection is unstable or even unavailable
  • you prioritize privacy over accessibility and prefer to tát store emails on the local machine
  • you’re the only person with access to tát your tin nhắn tài khoản and use a single device for that purpose

If you still don’t know which protocol to tát choose, kiểm tra out our article on the key differences between IMAP and POP3 or watch this video:

What about HTTP? 

HyperText Transfer Protocol (HHTP) is another option to tát access emails, yet it’s not an tin nhắn protocol. Regardless, HTTP can be used to tát send and receive messages from webmail, such as Gmail.com. It’s also good practice to tát access emails in mobile apps through HTTP. 

This protocol has two mặc định ports: 80 for non-encrypted and 443 for secure connections. 

How an tin nhắn gets from a sender to tát a recipient 

Now, you know what each tin nhắn protocol is used for. Let’s map a full picture of how an electronic message can get from a sender ([email protected]) to tát a recipient ([email protected]). 

  • Sender’s tin nhắn client connects to tát the SMTP server (for example, smtp.gmail.com)
  • The SMTP server authenticates the recipient’s tin nhắn address using DNS records (for more information on tin nhắn authentication, read our blog posts about SPF, DKIM, DMARC, and BIMIrecords or watch videos on our YouTube channel)
  • Once the Gmail SMTP server authorizes the recipient, it sends the tin nhắn to tát the SMTP server of recipient.com
  • Recipient.com’s SMTP server verifies whether [email protected] is valid
  • The SMTP server forwards the tin nhắn to tát the IMAP/POP3 server

Is it enough to tát mix up tin nhắn protocols to tát send and receive emails successfully?  

The short answer is no. While properly-set-up tin nhắn protocols are essential, they are certainly not enough. You need a safe tin nhắn infrastructure with built-in deliverability tools to tát reach recipients’ inboxes.

To learn more about what an tin nhắn infrastructure is, kiểm tra out our dedicated video:

Along with an tin nhắn infrastructure, you may also need a virtual inbox to tát receive all your test emails. 

Mailtrap is a single platform that takes care of all your email-related needs. Test your emails using a nhái SMTP server provided by E-Mail Testing, send your emails with E-Mail Sending’s reliable SMTP server, and monitor the performance of your infrastructure. All of that within one E-Mail Delivery Platform. 

Mailtrap trang chính page

Email Testing is an E-Mail Sandbox that captures all your SMTP traffic. You can use it to tát kiểm tra the tin nhắn sending functionality of your phầm mềm and see whether the SMTP server is configured properly. With E-Mail Testing’s HTML Check and Spam Analysis features, you’ll tackle deliverability issues before your phầm mềm hits the production environment. 

Mailtrap E-Mail Testing - inbox

Once you’re done with testing, you can configure your phầm mềm to tát use E-Mail Sending’s SMTP server that delivers your emails to tát the inboxes in seconds. Alternatively, integrate Mailtrap with API for more flexibility. Whichever method you choose, you’ll get access to tát E-Mail Sending’s unique monitoring capabilities – actionable analytics with drill-down reports and helicopter-view dashboards. 

Mailtrap E-Mail Sending Stats

Here’s what the tin nhắn delivery flow will look lượt thích if you were to tát use Mailtrap’s E-Mail Sending or E-Mail Testing: 

  • Sender’s tin nhắn client connects to tát the real or nhái SMTP server (live.smtp. and sandbox.smtp., respectively). Mailtrap provides all the required credentials lượt thích port, username, password, and authentication method. 
  • If you’re using E-Mail Testing, the nhái SMTP server will send an tin nhắn to tát the POP3 server (pop3.).
    • You’ll see your message in your Demo inbox if your phầm mềm functions properly. 
  • If you’re using E-Mail Sending, the emails will be directed to tát the recipients’ POP3 or IMAP servers.
    • In a matter of seconds, they will pop up in your recipients’ inboxes. 

For more information on integrating and using Mailtrap, refer to tát our getting started guide. 

We hope our blog post on IMAP vs POP3 vs SMTP helped clarify the complicated world of emails.