This post gives a basic overview of the theory of operation of Electronic Mail (Email).
Email basically uses two types of protocols, namely a push protocol and a pull protocol, for enabling end computers/users to send and receive mails. While SMTP (Simple Mail Transfer Protocol) is the primary Mail Transfer Agent (MTA) protocol used for transferring (pushing) mails between end computers and mail servers, Mail Access Agent (MAA) protocols like POP3/IMAP are used for retrieving (pulling) incoming mails from the local mail servers.
In the case of web-based email, HTTP is used as the carrier protocol in the first and last segments of an email, by the sender for sending the mail to the local mail server and by the receiver to retrieve the mail from the receiver’s mail server.
Since email has to be delivered in a reliable manner by the network, all email carrier protocols use TCP as the underlying transport layer protocol.
The diagram given below illustrates the email path and the list of email carrier protocols used when two users named Alice and Bob exchange emails through the internet. While the red arrows show the path taken by mails sent from User Alice to User Bob, the blue arrows show the path taken by mails sent by User Bob to User Alice.
As given in the above diagram,
- Sending of emails typically involves at least four computers, namely the sending computer, the sending computer’s local mail server, the receiving computer’s mail server and the receiving computer, with the network being the carrier.
- An email sent by an end user is first transferred to its local mail server, using SMTP (normally) or HTTP (in the case of web based mail alone) as the carrier protocol. The local mail server then transfers the mail to the recipients mail server, again using SMTP as the carrier protocol. The mail is then retrieved from the receiver’s mail server by the receiving computer through a pull protocol like POP3 or IMAP or HTTP (web based email alone). This is clearly illustrated in the above diagram by a red path (for mails sent from Alice to Bob) and by a blue path (for mails sent from Bob to Alice)
- User Agents (UAs): At the end computers (sender and receiver), entities known as UAs help the end user in sending and retrieving emails. Functions of UAs include providing GUI or command based interfaces to compose, forward, redirect and receive mails. The UAs interact with an MTA client protocol to transfer outgoing mails sent by the user to the local mail server and also interact with an MAA client protocol to retrieve the user’s incoming mail from the local mail server. Eudora, Outlook Express, elm, pine etc. are examples of UAs.
- Mail Servers : Since the end user computers cannot be online always, dedicated mail servers do the duty of sending and receiving mails for multiple end users, by remaining always on. Mail servers typically run both the client and the server instances of an MTA protocol like SMTP. While the MTA client instance protocol is used to send mails to remote mail servers, the MTA server instance protocol is used to receive mails from both end computers and from remote mail servers. Apart from this, mail servers run the server instance of a MAA protocol (like POP3/IMAP), to retrieve mails from the inbox of users and send it to the respective user’s computer, when requested through an MAA client instance protocol.
- SMTP is the primary MTA protocol used between mail servers and also between end clients and mail servers, for sending mails.
- SMTP is a
- Is a simple text-based protocol that enables users to send emails
- It is a push protocol because it is used to push an email from a sender to the receiver.
- Is an application layer protocol running on top of TCP. SMTP server typically waits on TCP port number 25.
- Though it supports sending mails only in ASCII format, it allows extensions in the form of MIME (Multipurpose Internet Mail Extensions) for carrying a wide variety of data formats including binary, images, audio, video etc.
- It is a text based, Request – Response, client server protocol, with simple messages like HELO, Mail From, RCTP TO, DATA etc. A sample SMTP session of an email is given in the diagram below:
As given in the diagram above, SMTP also supports sending emails to multiple recipients and also to mail aliases.
MAA protocols (POP3/IMAP) : The MAA protocols like POP3/IMAP are used in the last hop of an email for retrieving incoming mails by the end user from his/her local mail server. While both POP3 and IMAP are pull protocols, used for retrieving mails from the local mail server to the receiving computer’s Inbox, IMAP is a more powerful protocol than POP3. IMAP supports additional features like creation and management of multiple folders in the mail server, accessing mails from multiple end points etc.
Role of HTTP in email : Web based emails like yahoo, gmail use HTTP as the underlying protocol for sending outgoing email messages from the end computer to the local mail server and also for retrieving incoming mail messages from the local mail server to the end computer. However, HTTP is not used in the intermediate hops, for transferring emails between mail servers. Only SMTP is used for transfer of mails between mail servers.