How E-mail works?
Electronic Mail or email as we call it, has been one of the most integral and most used feature of Internet.
But did you ever thought,
How Email works?
In this post will take a look at how email functions, travels and is sent to the recipient, step by step.
Before starting,
You should have a brief idea about SMTP.
SMTP stands for Simple Mail Transfer Protocol.
Every mail provider has its own SMTP server working on default port number 25.
This SMTP does the job of sending and receiving mails to and from different mail providers.
Suppose Ram having an Email address [email protected] wants to send an email to Shyam.
Now there can be two scenarios.
- Either Ram will send an email to Shyam’s email address, having the same domain i.e. the recipient would be using a Gmail id too.
OR - Shyam would be using email address provided by different mail provider.
We will take the first Scenario :
Ram writes an email with some contents to [email protected].
the following process takes place afterwards :
- The SMTP (Simple Mail Transfer Protocol) will take over the mail. It will note the sender’s IP address,
and then break the recipient’s address in two parts, one before @ and one after. - So it would be ‘shyam’ and ‘gmail.com’
- It then checks the domain, here it is ‘gmail.com’.
- So it understands that this email is for a recipient of the same domain.
- So the SMTP will simply send it to POP3/IMAP server.
- The POP3/IMAP server will check if email recipient is valid or not, that is, Ifshyam really exists in gmail.com.
- If yes, it does various Virus scans, and spam checking.
- If the mail passes all these tests,
The next time Shyam logs in into his account those new mails would be downloaded into his inbox.
- If Shyam doesn’t exists, then it will send an email to Ram with subject:
Delivery Status Notification (Failure) and the details of failure in the message body.
Now let us have a look at the second scenario
When email is being sent to some other mail server.
Here the process is little complicated, since the mail service providers are different.
- When Ram clicks on send button, the SMTP will note the sender’s IP address, and then
break the recipient’s address and check the domain name. - Ram is now sending to [email protected].
- The SMTP understands that, it has to send the mail to an external SMTP.
- But SMTP of Google doesn’t know the IP address of SMTP of Yahoo, so where does it goes for help????
- The DNS server comes for the rescue.
Google’s SMTP would go to DNS, and ask the Name Server for the Mail exchanger address of yahoo.
The DNS will check its database, and then give the IP of yahoo’s SMTP to Gmail’s SMTP. - Now Gmail has the mail , and the address to which it has to send. So it will send that mail through various Mail Transfer Agent (MTA) present on internet, to the Yahoo’s SMTP.
- When Yahoo’s SMTP receives this email, it will check at the recipient’s address first.
If it finds ‘@yahoo.com’, It will make a header file, containing the sender’s IP address and the IP address of SMTP through which it received. - Yahoo’s SMTP would then check, if the user to whom the mail is sent actually exists or not, in yahoo’s mail server.
- IF he does exists, the SMTP will send it to the POP3/IMAP server where various Virus Scans and attachment Scans, and Spam checking would take place.
- If the mail passes all these tests, it would then be stored in its database.
When Shyam logs in into his yahoo id, the mail would be downloaded into his inbox. - If Shyam doesn’t exists, it will send a ‘Failure Notice’ to the SMTP of Google.
So if you read this you must be wondering What is POP3 and IMAP servers?
Well, if you have used external Mail clients like Mozilla’s Thunderbird or Microsoft’s Outlook, you have to configure your mail address. Here the Client asks you whether you need to use IMAP or POP3.
In POP3
- Email is stored in your machine.
- It is also available, when you’re offline.
- If you receive lots of emails daily, your disk consumption on server is less if you use POP3.
- But then you can’t access your mails from other machines.
- If mail is deleted from your machine, you can’t find it on your mail server.
In IMAP
- Mail is accessible from everywhere.
- If mail is deleted from your device, it is still present in your server.
- If you use your device to read a mail, it would be marked as read on the server too.
- But, you cannot check your mails, if you’re not connected to Internet.
Generally IMAP settings is configured in your Mobile devices.
Very well Explained…thanx..
Can you write an article on how to host an intranet website with Email server. where the local emails should be able to communicate with each other as well as with the emails on the web (e.g gmail).