SMTP:
Email is emerging as one of the most valuable services on the internet today. Most internet systems use SMTP as a method to transfer mail from one user to another. SMTP is a push protocol and is used to send the mail whereas POP (post office protocol) or IMAP (internet message access protocol) are used to retrieve those emails at the receiver’s side.
SMTP Fundamentals
SMTP is an application layer protocol. The client who wants to send the mail opens a TCP connection to the SMTP server and then sends the mail across the connection. The SMTP server is an always-on listening mode. As soon as it listens for a TCP connection from any client, the SMTP process initiates a connection through port 25. After successfully establishing a TCP connection the client process sends the mail instantly.
SMTP Protocol
The SMTP model is of two types:
- End-to-end method
- Store-and- forward method
- The end-to-end model is used to communicate between different organizations whereas the store and forward method is used within an organization. An SMTP client who wants to send the mail will contact the destination’s host SMTP directly, in order to send the mail to the destination. The SMTP server will keep the mail to itself until it is successfully copied to the receiver’s SMTP.
The client SMTP is the one that initiates the session so let us call it client- SMTP and the server SMTP is the one that responds to the session request so let us call it receiver-SMTP. The client- SMTP will start the session and the receiver-SMTP will respond to the request. - Model of SMTP system
- In the SMTP model user deals with the user agent (UA), for example, Microsoft Outlook, Netscape, Mozilla, etc. In order to exchange the mail using TCP, MTA is used. The user sending the mail doesn’t have to deal with MTA as it is the responsibility of the system admin to set up a local MTA. The MTA maintains a small queue of mails so that it can schedule repeat delivery of mails in case the receiver is not available. The MTA delivers the mail to the mailboxes and the information can later be downloaded by the user agents.

Both the SMTP-client and SMTP-server should have 2 components:
- User-agent (UA)
- Local MTA
Communication between sender and the receiver :
The sender’s user agent prepares the message and sends it to the MTA. The MTA’s responsibility is to transfer the mail across the network to the receiver’s MTA. To send mails, a system must have a client MTA, and to receive mails, a system must have a server MTA.
SENDING EMAIL:
Mail is sent by a series of request and response messages between the client and the server. The message which is sent across consists of a header and a body. A null line is used to terminate the mail header and everything after the null line is considered as the body of the message, which is a sequence of ASCII characters. The message body contains the actual information read by the receipt.
RECEIVING EMAIL:
The user agent at the server-side checks the mailboxes at a particular time of intervals. If any information is received, it informs the user about the mail. When the user tries to read the mail it displays a list of emails with a short description of each mail in the mailbox. By selecting any of the mail users can view its contents on the terminal.
Some SMTP Commands:
- HELO – Identifies the client to the server, fully qualified domain name, only sent once per session
- MAIL – Initiate a message transfer, fully qualified domain of originator
- RCPT – Follows MAIL, identifies an addressee, typically the fully qualified name of the addressee, and for multiple addressees use one RCPT for each addressee
- DATA – send data line by line
POP:
The POP protocol stands for Post Office Protocol. As we know that SMTP is used as a message transfer agent. When the message is sent, then SMPT is used to deliver the message from the client to the server and then to the recipient server. But the message is sent from the recipient server to the actual server with the help of the Message Access Agent. The Message Access Agent contains two types of protocols, i.e., POP3 and IMAP.

Suppose sender wants to send the mail to receiver. First mail is transmitted to the sender’s mail server. Then, the mail is transmitted from the sender’s mail server to the receiver’s mail server over the internet. On receiving the mail at the receiver’s mail server, the mail is then sent to the user. The whole process is done with the help of Email protocols. The transmission of mail from the sender to the sender’s mail server and then to the receiver’s mail server is done with the help of the SMTP protocol. At the receiver’s mail server, the POP or IMAP protocol takes the data and transmits to the actual user.
Since SMTP is a push protocol so it pushes the message from the client to the server. As we can observe in the above figure that SMTP pushes the message from the client to the recipient’s mail server. The third stage of email communication requires a pull protocol, and POP is a pull protocol. When the mail is transmitted from the recipient mail server to the client which means that the client is pulling the mail from the server.
What is POP3?
The POP3 is a simple protocol and having very limited functionalities. In the case of the POP3 protocol, the POP3 client is installed on the recipient system while the POP3 server is installed on the recipient’s mail server.

To establish the connection between the POP3 server and the POP3 client, the POP3 server asks for the user name to the POP3 client. If the username is found in the POP3 server, then it sends the ok message. It then asks for the password from the POP3 client; then the POP3 client sends the password to the POP3 server. If the password is matched, then the POP3 server sends the OK message, and the connection gets established. After the establishment of a connection, the client can see the list of mails on the POP3 mail server. In the list of mails, the user will get the email numbers and sizes from the server. Out of this list, the user can start the retrieval of mail.
Once the client retrieves all the emails from the server, all the emails from the server are deleted. Therefore, we can say that the emails are restricted to a particular machine, so it would not be possible to access the same mails on another machine. This situation can be overcome by configuring the email settings to leave a copy of mail on the mail server.
Advantages of POP3 protocol
The following are the advantages of a POP3 protocol:
- It allows the users to read the email offline. It requires an internet connection only at the time of downloading emails from the server. Once the mails are downloaded from the server, then all the downloaded mails reside on our PC or hard disk of our computer, which can be accessed without the internet. Therefore, we can say that the POP3 protocol does not require permanent internet connectivity.
- It provides easy and fast access to the emails as they are already stored on our PC.
- There is no limit on the size of the email which we receive or send.
- It requires less server storage space as all the mails are stored on the local machine.
- There is maximum size on the mailbox, but it is limited by the size of the hard disk.
- It is a simple protocol so it is one of the most popular protocols used today.
- It is easy to configure and use.
Disadvantages of POP3 protocol
- If the emails are downloaded from the server, then all the mails are deleted from the server by default. So, mails cannot be accessed from other machines unless they are configured to leave a copy of the mail on the server.
- Transferring the mail folder from the local machine to another machine can be difficult.
- Since all the attachments are stored on your local machine, there is a high risk of a virus attack if the virus scanner does not scan them. The virus attack can harm the computer.
- The email folder which is downloaded from the mail server can also become corrupted.
- The mails are stored on the local machine, so anyone who sits on your machine can access the email folder.
IMAP: What is IMAP (Internet Message Access Protocol)?
Internet Message Access Protocol, or IMAP, is a standard email retrieval (incoming) protocol. It stores email messages on a mail server and enables the recipient to view and manipulate them as though they were stored locally on their device(s).
IMAP enables users to organize messages into folders, flag messages for urgency or follow-up, and save draft messages on the server. Users can also have multiple email client applications that sync with the email server to consistently show which messages have been read or are still unread.
How does IMAP work?
As an incoming email protocol, IMAP functions as the intermediary between the email server and email client. When users read an email using IMAP, they read them off the server. They don’t actually download or store the email on their local device. This means that the email is not tied to a particular device, and users can access it from any location in the world using different devices, such as the following:
- desktop PC
- laptop
- smartphone
- tablet
These are the general steps and processes involved in an IMAP operation:
- When a user signs into the email client — e.g., Microsoft Outlook — the client contacts the server using IMAP.
- The connection is made on a specific port.
- The headers of all emails are displayed by the email client.
- IMAP only downloads a message to the client when the user clicks on it; attachments are not automatically downloaded.
- Users can check their messages much more quickly with IMAP than with other email retrieval protocols, like Post Office Protocol 3 (POP3).
- Email messages remain on the server unless the user explicitly deletes them.
An IMAP server listens on port number 143, while IMAP over Secure Sockets Layer (SSL)/Transport Layer Security is assigned port number 993.
IMAP, TCP and HTTP
Most modern client-server protocols operate between a web browser and a server or an app and an application programming interface (API). APIs are implemented on top of the base protocol, Hypertext Transfer Protocol (HTTP). HTTP is implemented on top of TCP, which ensures that data packets are delivered to their intended destination.
Like HTTP, IMAP is also implemented on top of TCP. It works based on different types of requests, known as IMAP commands. A command in IMAP is similar to a request in HTTP. It either tells the server to do something or asks the server for some information.
An IMAP command generally looks like this:
<tag> <command> [<arg1><arg2>…]
In the early ’90s, when network connections had low bandwidth, HTTP was important for IMAP.
Adding email accounts to IMAP
When an email account is added to an email app or client, it will usually attempt to set it up with IMAP access. In that case, user inputs are not required. But, if the account is already set up for POP3, the client may have difficulty adding the account to IMAP.
If users still need to configure their account with IMAP, they need to get the names of the POP3 and Simple Mail Transfer Protocol (SMTP) — outgoing mail — server from the email provider and then enter this information into the client:
- IMAP server: imap.<name of service>.com
- POP3 server: pop.<name of service>.com
- SMTP server: smtp.<name of service>.com
Differences between IMAP and POP3
Like IMAP, POP3 is also a client-server email retrieval protocol. However, there are differences between the two protocols. With POP3, email is saved for users in a single mailbox on the server. It is moved from the server to their device when the mail client opens.
While POP3 can be thought of as a “store-and-forward” service, IMAP can be thought of as a remote file server, since the user can store the email on the server and access it from any device or location as needed.
Advantages and limitations of IMAP
Advantages
Most implementations of IMAP support multiple logins. This enables users to simultaneously connect to the email server from different devices. For example, users simultaneously could access their email with an Outlook app on an iPhone, as well as an Outlook desktop app.
Multiple accesses are not possible with POP3, where downloaded emails disappear from the server and, therefore, cannot be accessed from a different device later. So, POP3 is only suitable when users access their email from the same device every time.
IMAP provides greater access flexibility for users who travel often or need to check their email from different devices or locations. The details for how to handle multiple connections are not specified by the protocol, but are instead left to the developers of the mail client.
In brief, the advantages of IMAP are the following:
- emails accessible from multiple devices;
- fast and efficient access;
- a single mailbox can be shared by multiple users;
- users can organize emails on the server by creating folders and subfolders;
- support for email functions, like search and sort;
- IMAP server supports IDLE extensions (push mail) so the email is displayed in the inbox as unread, eliminating the need to set up a polling interval or requiring users to first click on receive; and
- can be used offline.
Limitations
Even though IMAP has an authentication mechanism, the authentication process can easily be circumvented by anyone who knows how to steal a password by using a protocol analyzer because the client’s username and password are transmitted as cleartext.
In an Exchange Server environment, administrators can work around this security flaw by using SSL encryption for IMAP.
In general, IMAP is a popular email retrieval protocol. Its popularity is growing due to the proliferation of mobile devices, such as smartphones and tablets. IMAP is ideal for those who need to access their email on the go or using different devices.