How does email work? A dummies guide
I had originally posted this on my Medium blog. Since I am moving all my writing to Substack crossposting it here as well:-)
During my initial days at Mailmodo, I was amazed by the number of emails we sent out every day. In April 2022, we sent 36.52 million emails. That’s an average of 1.21 Million emails per day.
As a newbie intern, I was naturally intrigued by these figures. How do you send out this volume of emails while maintaining excellent deliverability? As a learned more, I realized how technology has this amazing ability to make complex things look incredibly simple and emails were also a part of this magic.
So, I jotted down everything I learned to help you understand the mechanics of email in simple terms. The objective of this article is to -
Explain how email works without diving into the technical nitty gritty.
Appreciate the simple yet complex technology behind emails.
Let’s start!
How emails work
So, you compose a fancy leave application. You hit send, and bam, it gets delivered to your boss’s inbox. Seems pretty simple, right? Not really. Let us trace the journey of an email.
Step 1
You compose your leave application on Gmail. Here, Gmail is your email client. An email client is web or desktop-based software that lets you send and receive emails. Other popular clients include Apple Mail, Outlook, Yahoo, Mail.ru, etc.
Step 2
Your email goes to an SMTP server, where it waits for its turn to be processed.
A server is just a computer whose job is to serve. SMTP stands for Simple Mail Transfer Protocol. A protocol is a set of rules. SMTP protocol is nothing more than a set of rules for transmitting emails.
So, the client (Gmail) sends the email to a computer (i.e server) that follows a certain set of rules (i.e SMTP protocol) to make sure that your email is transmitted correctly.
The SMTP server doesn’t know where to send the email. It just knows the email address of the recipient.
Let's take a detour to understand a few key ideas
Let us say that a US citizen wants to send a letter to the president. The citizen writes this in the receiver’s address -“The White House”. The citizen drops the letter in a post box, from where it gets collected by the postman. The postman sees the receiver’s address as “The White House”. So, he drops the letter to his favourite cafe called “The White House” which is two blocks away.
The postman only knew the name of the place where the letter was supposed to be delivered, not the actual address. If the citizen had written the address as 1600 Pennsylvania Avenue, NW Washington D.C. 20500, U.S. then the letter would have been delivered at the correct address.
For emails, the name of the place where the letter is supposed to be delivered is called the domain. A domain is a part that comes after “@” in an email address. The most common domain name is gmail.com. If you had a custom email address like john@pizza.com, then pizza.com would be your domain name.
IP address stands for internet protocol address. IP address is the actual address where the letter is supposed to be delivered. Put simply, it tells us where a device is located on the internet (or a network).
In our example, “The White House” is the domain and “1600 Pennsylvania Avenue, NW Washington D.C. 20500, U.S” is the IP address.
Coming back to our email journey, the SMTP server knows the domain name of the recipient (To:boss@company.com; Domain: company.com). Now, the SMTP server needs to know the IP address of this domain. For this, it will contact another computer(server) and ask for the IP address corresponding to the domain “company.com”. This computer is called the DNS server.
DNS stands for Domain name system. It is a big address book of the internet.
Step 3
The SMTP server asks the DNS server, can you tell me the IP address of this server? The DNS server checks its records and returns the IP address of the domain. Now the SMTP server knows the exact address where it is supposed to send the email.
Step 4
Now, the sender’s SMTP server needs to establish a connection with the receiver’s SMTP server. For this, the SMTP server will pass on the IP address to the sender’s router.
A router is a device that connects your network to the internet. A network is just a collection of computers connected with each other.*
The router will take the IP address and find the fastest path to the receiver’s SMTP server. The connection (an electrical signal following physical and digital paths) will go into the internet where it will hop over multiple routers located across the world. Consider each router as a rest house for the electrical signal (i.e the connection). The router will tell the signal, this is the path you must follow to reach your destination efficiently.
The last hop will take the connection to the recipient’s router. The router will forward the connection to the receiver’s SMTP server. Now, the sender SMTP server and the receiver SMTP server will have a conversation-
Sender SMTP- “Hello”
Receiver SMTP- “Hello”
Sender SMTP- “I want to send an email”
Receiver SMTP- “Let me run some checks to make sure you are genuine and not masquerading as someone else”
If the receiver SMTP is able to authenticate the sender, it will respond with “OK”. This will establish a successful connection between the sender SMTP server and receiver SMTP server.
Note- The email has not been sent yet. We have only established a connection up til now.
Step 5
After establishing a connection, the sender SMTP server will push the email to the router. The router will break the email into smaller packets.
Consider the email as an assembled jigsaw puzzle. Each individual piece of this puzzle is called a packet. These pieces are sent one by one over the established connection (via a series of routers). Once all the individual pieces have reached the receiver’s router, they will be assembled back to form the original email.
Step 6
The router will deliver the email to the receiver’s SMTP server. The SMTP server will check the email for potential spam. If everything is OK, then the email will be sent to another computer called IMAP/POP3 server.
Note- While establishing the initial connection, email sender was authenticated. Now we are checking the email content.
Step 7
IMAP/POP3 server follows a certain set of rules to make sure your email is delivered to the recipient’s email client. This computer would be following POP or IMAP protocol. POP stands for post office protocol while IMAP stands for Internet message access protocol. IMAP is a better way to retrieve and deliver emails to the client.
Step 8
This POP3/IMAP server will send the email to the recipient’s email client. The email client will again check the email against a series of spam rules and place the email in an appropriate folder like promotions, spam, social or primary.
That’s it, your boss has received your leave application. This entire journey is completed in a few seconds after you hit send. The next time you send an email, be sure to appreciate all the wonderful tech that goes behind it.
Some jargon (feel free to skip this part️️)
Email client is also known as MUA (Mail user agent), SMTP server is also known as MTA (Mail transfer agent) and IMAP/POP3 server is also known as MDA (Mail delivery agent). MTA and MDA are programs that run on the SMTP server and IMAP/POP3 server respectively.
You might have also heard about MSA(Mail submission agent). It acts as a bridge between the email client (MUA) and the SMTP server(MTA). Its job is to detect and report errors. Most of the MTAs perform the function of MSA as well.
The DNS server will return the IP address corresponding to the domain in the form of an MX (Mail exchanger) record.
TLS (Transport layer security)- It prevents the email from being read by someone who has access to the network through which your email is traveling. Read more about email encryption here.
Learn more about the structure of an email here. SPF, DKIM, and DMARC are email authentication methods (refer to step 4). You can read more about them here (Understand the structure of an email before diving into email authentication methods).
We at Mailmodo are transforming traditional bland emails into app-like experiences. Do check us out here.
Happy emailing:-)
Sources-
SMTP - What is SMTP, Meaning, How it Works, Types
Message transfer agent - Wikipedia
How does email work? Ultimate Guide by Namecheap
*A router connects devices on a network. It is the modem which connects the router to the internet; ultimately connecting your devices to the internet.