The e-mails are a asynchronous communication medium and are based on three major components: user agents, mail server and SMTP protocols.
User agents are the interface that users utilize to send and receive messages. A message is usually sent from the sender’s user agent to the sender’s server. Once there, the message is sent by the sender’s server to the recipient’s server and finally, from there, to the recipient’s user agent. The first two step (user-agent $\rightarrow$ mail-server, mail-server $\rightarrow$ mail-server) use the SMTP protocol whereas the last step (mail-server $\rightarrow$ user-agent) utilize a different protocol.
It uses only $7$ bit ASCII messages and it uses TCP as underline protocol. When the sender user agent instruct the sender mail server to send an email a TCP connection between the sender mail server and the the recipient mail server is opened on port $25$ (if the the server is down the sender will try again later). The sender mail server indicates the sender email address, the recipient email address and a message to be sent.
In a SMTP communication $5$ commands are used:
QUIT. After the
DATA command a dot indicates the termination of the message and if there were no error the message is ready to be sent. It’s possible to send several messages with during the same communication since SMTP utilize persistent TCP connections. A connection is close only after the
SMTP is a push protocol since data is usually pushed from host to host (HTTP is a pull protocol because it’s the client that pull data from the server).
POP3 is the protocol used by the recipient user agent to retrieve data from the recipient’s mail server. The protocol uses the port $110$ and each connection goes through three phases:
- Authorization - the user agent send username and password in clear to the mail server
- Transaction - the user agent retrieves messages and can interact with them (deleting, marking, …)
- Update - the client send the
quitcommand and the server update the state of the messages.
POP3 can be configured both as download-and-delete and download-and-keep mode.
IMAP has many more functionality than POP3. In general every message is associated with a folder and messages can be moved from folder to folder. It also allows to retrieve specific messages giving some parameters and other functionality.
IMAP have to keep a state for each user (for example where the messages are locate) whereas POP3 is stateless.
Web Based e-mail
It’s possible to use HTTP instead of POP3/IMAP, this happens in the web base user client where the HTTP client (the browser) contact the server (the mail server). It also possible for HTTP to be sued in the first step (when the sender user agent contact the sender mail server).r