How Email Works?
Email communication is a complex process involving various servers and protocols to ensure that messages are sent, received, and managed securely and efficiently. Here's a step-by-step breakdown of how an email travels from a sender to a recipient.
Sender Mail Client​
-
Imagine Shubh wants to send an email to his friend Parth. Shubh composes the email using his mail client, such as Outlook.
-
Shubh's mail client submits the email to the Mail Submission Agent (MSA) on his outgoing mail server using the Simple Mail Transfer Protocol (SMTP).
Mail Submission Agent (MSA)​
-
The MSA on Shubh's outgoing mail server receives the email from the mail client.
-
The MSA authenticates Shubh's credentials (username and password) sent by the mail client. This is why logging into the mail client is necessary.
-
After successful authentication, the MSA forwards the email to the Mail Transfer Agent (MTA).
Mail Transfer Agent (Sender MTA)​
-
The sender's MTA takes over and looks up the recipient’s domain (
mail.gmail.com
) using DNS to find the IP address of the recipient's mail server. -
The MTA attempts to transfer the email to the recipient's mail server via SMTP.
-
If the recipient’s server is unavailable, the MTA queues the email for periodic retry until it is successfully delivered. This non-blocking message queue ensures that emails are not lost even if there are temporary network issues.
Mail Transfer Agent (Receiver MTA)​
-
The MTA has two primary functions:
-
Sending emails to other MTAs.
-
Sending emails to the local Mail Delivery Agent (MDA) if the recipient's domain matches the server's configuration.
-
-
How does the MTA decide what to do? If the email is destined for a user within its domain (e.g.,
gmail.com
), it sends the email to the MDA. Otherwise, it forwards the email to the appropriate external MTA.
Mail Delivery Agent (MDA)​
-
The MDA performs tasks such as spam filtering to ensure unwanted emails do not reach the user's inbox.
-
After filtering, the MDA delivers the email to Parth’s mailbox. Parth's mailbox is a specific directory or database entry within the server designated for his account.
-
The mailbox might look something like this:
/parth
inbox/
- Email from Rahul (unread)
- Email from Karan (unread)
- Newsletter from Example Company (read)
- Email with attachment (unread)
sent/
- Email to Rahul
- Email to Karan
drafts/
- Unfinished email to Rahul
Receiver Mail Client​
-
Parth wants to check his email, so he uses his email client (such as a web-based client like Gmail or a mobile app).
-
Parth's email client connects to the IMAP server using his credentials (email address and password).
IMAP Server (Internet Message Access Protocol)​
-
The IMAP server authenticates Parth's credentials to ensure he is authorized to access his mailbox.
-
Once authenticated, the IMAP server grants Parth access to his mailbox.
-
The IMAP server allows Parth’s mail client to fetch and manage emails stored in his mailbox, providing the capability to organize, read, and delete messages directly on the server.
-
If Parth uses a mobile app, the email is downloaded and synchronized with his email client, so he can access his messages offline as well.