# Topic covered
* Mail Protocol
  * Simple Mail Transfer Protocol
  * POP3 vs IMAP
  * SMTP & POP & IMAP
* WebSocket

Simple Mail Transfer Protocol

SMTP is a process and set of guidelines that almost every email needs to go through in order to leave one outbox and arrive at another person’s inbox. An SMTP server is only used to send, receive, and transfer email.

Why is SMTP Important?

While sending one email is fairly simple, for larger organizations that send thousands or millions of marketing or transactional email, the SMTP process can get much more complicated, requiring SMTP relay service and custom headers for multiple recipients.

What is an SMTP mail relay?

SMTP mail relay is the process of transferring an email from one server to another for delivery. One server accepting an email from another server is “relaying.”

POP3 vs IMAP

IMAP and POP3 are both protocols used for retrieving email from an email server so you can read messages on your device. They’re used when connecting to your email account from a desktop email app, like Thunderbird, Outlook, Apple Mail, Spark, or similar.

POP or Post Office Protocol was created in 1984 as a way to download emails from a remote server. POP3 is still the current version of the protocol, though this is often shortened to just POP. POP3 is an older protocol that was originally designed to be used on only one computer.

Unlike modern protocols that use two-way synchronization, POP3 only supports one-way email synchronization, only allowing users to download emails from a server to a client.

IMAP or Internet Message Access Protocol, was designed in 1986. Instead of simply retrieving emails, it was created to allow remote access to emails stored on a remote server. The current version is IMAP4, though most interfaces don’t include the number.

With IMAP accounts, messages are stored in a remote server. Users can log in via multiple email clients on computers or mobile device and read the same messages. All changes made in the mailbox will be synced across multiple devices and messages will only be removed from the server if the user deletes the email.

The primary difference is that POP downloads emails from the server for permanent local storage, while IMAP leaves them on the server while caching (temporarily storing) emails locally. In this way, IMAP is effectively a form of cloud storage

SMTP & POP & IMAP

  • Simple Mail Transfer Protocol & Post Office Protocol & Internet Message Access Protocol
  • SMTP & POP is both synchronous and asynchronous
  • Usage
    • SMTP - for pushing the emails to mail server
    • POP/IMAP - for retrieving the email from a mail server
  • SMTP Port 25
  • POP3 uses Port
    • 110 - default non-encrypted port
    • 995 - secured/encrypted port(SSL)
  • IMAP
    • 143 - default
    • 993 - SSL
  • It also used MIME(Multipurpose Internet Mail Extensions)

WebSocket

WebSocket is a protocol that provides full-duplex communications over TCP. Clients establish WebSockets to receive real-time updates from the back-end services. Unlike REST, which always “pulls” data, WebSocket enables data to be “pushed”. Applications, like online gaming, stock trading, and messaging apps leverage WebSocket for real-time communication.

Websockets - https://www.youtube.com/watch?v=1BfCnjr_Vjg

Web sockets are a way of establishing a two-way communication between a client and a server over a single TCP connection. Web sockets are different from HTTP, which is a one-way communication where the client sends a request and the server sends a response.

Web sockets allow both the client and the server to send and receive data at any time, without closing the connection. This makes web sockets more efficient and suitable for real-time applications that require constant data exchange, such as chat, gaming, or streaming.