How Does Email Work?…

Avishka Shamendra
7 min readOct 30, 2020

Email is an important part of our day to day life and it is good to have an idea about how it works. I am pretty sure anyone who reads this has experience with emails. I don’t know about you, but per day I receive a bunch of emails, some very important, and some not so much. What would you do if you want to send an email? You may use the browser and log in to the email account and click “compose new” or “write new”. Then you type a message, add a sender’s address, add a subject, and press “send”. Magic! It appears in the other person’s inbox. Have you ever wondered how this works? Today let us look at how email works. A lot of things happen from the moment you press “send” to make the message appear on the receiver’s inbox. I will try to keep the explanations as simple as possible so everyone can understand.

Before going into how email works, let's look at what actually is an Email? Email in summary is sending a message between at least two people over the internet or any other computer network.

The Email Address

Forget about email for a second, if you are to write a letter to your friend and send it, what is the one thing you definitely should know? It is his/her residential address. In other words, the address of his post box. You send the letter, and it will end up in his post box and he will take it from the post box so that he can and read it. The same concept is applied in the email. Each email is sent to an email address and each email address corresponds to a mailbox. What is a mailbox? It is the same thing as the letter-box. It is to keep new and old emails. Mailboxes allow you to store email separately in folders (inbox, sent, spam, etc). I am pretty sure you have seen the format of an email address. It has three parts

  1. Username
  2. Host Name (examples:- Gmail, Facebook, Hotmail)
  3. Top-level Domain Name (examples:- com, org, lk)
Parts of an email address

Fun Fact about the @ symbol: In the early stages of email, Ray Tomlinson the inventor of email needed some character which is not found in names to separate the username and the hostname. So, he used the @ symbol

Components of an Email System

There are three main components of an email system

  1. Mail Client (Mail User Agent-MUA)

It is a software program that connects to the mail servers for outgoing and incoming mail. There are two main types of user agents and these are categorized according to how the emails are accessed, via installed software (email client) or the browser (webmail).

  • If we are to use an email client such as Mozilla Thunderbird, Microsoft Outlook, etc. users must install the user agent program on the user’s computer. The email client downloads and stores emails so the user can access them offline as well.
  • The other method is to access emails online via the browser. Web-based user agents such as Gmail, Hotmail store messages on their servers, and we can use the web browser to directly access the mail stored on servers.

2. Mail Server (Mail Transfer Agent-MTA/Mail Gateway)

A mail server receives an email from a client or another server and forwards it to another server. Another main function of the mail server is scanning for malware and spam. Also, it will store messages if the destination server is unavailable. Receiving MTA is especially known as Mail Delivery Agent(MDA). You will understand more about MTAs when you go through the rest of the article.

3. Message Store

Stores mail until it is accessed by the clients. Simply it is the collection of mailboxes on the server.

Simple Mail Transfer Protocol (SMTP)

SMTP is an email delivery protocol used to send an email over the internet. As the worldwide web uses HTTP to communicate here we use SMTP. It is simple and text-based. SMTP has a client-server model with a command response structure and is used to communicate between servers to send an email over the internet. The outgoing mail server is known as the SMTP server. When you hit “send”, the email is converted to a string of code and then sent to the SMTP server.

How An Email Is Sent ….

Structure of an email system

I will try to explain this as simply as I can. Let us say you want to send an email

  • First, the email is sent by the client to the sender’s mail server using SMTP and the mail server may validate the user and scan for malware and spam.
  • This mail server (SMTP mail server/sending mail server) acts as the post office and reads the destination address and try to figure out where to send the mail next. However, mail servers (SMTP) cannot understand domain names (for example So, the mail server contacts the Domain Name System (DNS) server to get the IP address related to the domain. A DNS server is like a phone book that maps domains on the internet to IP addresses of their servers.
  • Then sending server (SMTP) finds out whether the domain has any mail servers to receive emails using the MX (mail exchanger) record for that domain. If we go back to our letter analogy, this is like the sending post office finding out the correct receiving post office for the address specified.
  • Now the SMTP server has all the information needed to send the email to the domain’s mail exchange server (MTA). The message will be routed to the destination MTA directly or through other MTAs.
  • The receiving MTA decides where to put the incoming email, in which letter-box to put the letter so later the intended receiver can fetch the mail.

Receiving An Email

Up to here, we looked from the sender’s point of view on how the email is sent from one server to another. Now let us look at it from the receiver’s point of view.

  • The receiving mail server will first ask for the sender’s address and the sending server will provide this information using the envelope. The envelope is the same as in our letter analogy and it contains information about the email such as the sender’s and the receiver’s address. The envelope is a separate part of the email and it is mostly used by servers for mail transfer and end-users do not see it.
  • If the receiving mail server accepts the sender, the receiving server will ask the sending server for the destination address(receiver’s address).
  • If the mailbox of the receiver exists in the receiving server, the sending server will forward the email contained in the envelope.
  • The receiving server will scan the email for malware and spam. If it passes the scan the mail is put in the appropriate mailbox.
  • The receiving user agent can now access the mailbox and read the email.

There are two protocols in play here POP and IMAP. I will highlight only some major differences between these two protocols. POP3 is the commonly used version of POP.


POP- Post Office Protocol

POP is a simple protocol that only allows downloading messages from your mailbox to your local computer. Just like in a post office you can pop in and take your mail and leave. The email client can connect to the server and download the emails from the appropriate mailbox.

POP has some major drawbacks. If we fail to leave a copy of the email on the server when we are downloading, we will not be able to use more than one device to access our emails. Imagine you leave a copy, still POP is unidirectional, which means communication only happens from the server to the user. Once you get the emails from the server, it is up to the email client to manage them using different statuses (ex:- read, new, etc.). This was fine when we used to access email using only one device/client, but now we access our email using more than one device. Imagine you received a new email. You go to the server using the email client on your PC and you take that email from the server and you read it. Now your email client knows that you read the email but as POP is unidirectional, this information is not communicated to the server. So, when you use the mobile to access the emails the same email will be shown as a new email.

IMAP — Internet Message Access Protocol

IMAP is smarter than POP. IMAP allows for two-way communication. It always leaves a copy of every message on the server so unlike POP you can use multiple clients to access them. IMAP is fully synchronized. Any change you made in one client will be communicated to other clients via the server and emails can be directly organized on the server. If you read a new email on your mobile app and if you use the browser to check your emails later that email will be shown as read, unlike in POP. IMAP also has an offline mode where your changes will be synchronized once you connect again with the server. Users also can delete, rename, and organize emails on the server itself.

I am going to stop here. I think I have explained enough for you to get an idea about how emails work. I hope that you learned something new by reading this. Email is an important part of our day to day life and now you know how it works 😊

This was my first article and this is something new for me. Please add any comments or suggestions so I can improve my articles. 😊



Avishka Shamendra

Computer Science and Engineering Undergraduate at University of Moratuwa, Sri Lanka