How Email Works: Servers, SMTP, and Message Delivery

Summary

Pixel shares Part 5 of Networking Essentials for Software Engineers, explaining how email travels through mail servers and networking protocols. The article explores domain hosting, Gmail-to-Yahoo delivery, and how providers manage sending and receiving—useful context for understanding everyday internet communication.

DEV Community

Networking Essentials for Software Engineers – Part 5: How Email Actually Works

We use emails almost every day, whether it's for work or communicating with someone. Suppose you're using Gmail and want to send an email to your friend. You enter their email address, write your message, and click Send. That's all we do from our side. But have you ever wondered how Gmail knows where to send that email, especially if your friend uses Yahoo or another email provider? Just like HTTP, email also uses networking protocols to communicate between servers. Let's see how an email travels from our application to the receiver's inbox and understand the different protocols involved. How Does an Email Actually Travel? When we send an email, it doesn't go directly from our computer to the receiver's computer. It goes through email servers, which handle sending, receiving, and storing emails. But who manages these email servers? Some companies maintain their own mail servers, while others use email providers like Google, Microsoft, or Zoho. For example, suppose a company owns the domain example.com. It can set up its own mail servers to handle emails for addresses like [email protected]. Or it can use Google Workspace. Employees can still use [email protected], but Google takes care of sending and receiving their emails. So, having our own email domain doesn't mean we need to run our own mail servers. Now, let's see how an email travels when we send it from Gmail to Yahoo Mail. We'll also look at what changes when both people use Gmail or when we use a third-party email application like Thunderbird. Sending an Email from Gmail to Yahoo Mail Suppose you're using Gmail and want to send an email to your friend who uses Yahoo Mail. You open Gmail in your browser, write your message, enter your friend's email address, and click Send. Let's see what happens next. 1. Your email reaches Gmail's servers Since we're using Gmail in a browser, our email first reaches Google's servers through HTTPS, the same protocol we learned about in our previous article. Google receives the email and checks where it needs to be sent. 2. Gmail finds Yahoo's mail server Suppose your friend's email address is [email protected]. Gmail looks at the domain yahoo.com and needs to find which server receives emails for that domain. To find it, Gmail uses DNS and looks for a special record called an MX (Mail Exchange) record. An MX record tells us which mail servers handle incoming emails for a particular domain. Once Gmail finds the mail server's name, it can find its IP address and connect to it. 3. Gmail sends the email to Yahoo Now Gmail needs to transfer the email to Yahoo's mail server. For this, it uses SMTP (Simple Mail Transfer Protocol). SMTP is the protocol mail servers commonly use to send emails to each other. Gmail connects to Yahoo's mail server, sends the message, and receives a response telling it whether the email was accepted. 4. Yahoo receives and stores the email Once Yahoo accepts the email, it processes the message and delivers it to your friend's mailbox. Now, how does your friend read it? If they open Yahoo Mail in their browser, the browser uses HTTPS to communicate with Yahoo's servers and display the email. But if they're using a third-party email application like Thunderbird, it can use IMAP or POP3 to access emails from Yahoo's servers. We'll understand how IMAP and POP3 work shortly. What If Both of You Use Gmail? Now suppose you and your friend both use Gmail. When you click Send, your browser sends the email to Google's servers using HTTPS, just like in our previous example. But this time, Google doesn't need to find another email provider's mail server. Since your friend also uses Gmail, Google can handle the delivery within its own mail system and store the email in your friend's mailbox. Google may use SMTP or other methods to communicate between its internal servers, but it doesn't need to establish an SMTP connection with another email provider. What If We Use a Third-Party Email Application? So far, we've seen h...
How Email Works: Servers, SMTP, and Message Delivery
Powered by Readybot.io

The latest from Pixel

Incident Response: Look Beyond the Red Alert

Pixel’s DEV Community announcement explores how teams can fixate on one failing service while overlooking the real cause of an outage, such as a full …

Sach: AI Fact-Checks WhatsApp Forwards in India

Pixel’s announcement introduces Sach, a tool that checks forwarded messages in English, Hindi, Telugu, and 14 other Indian languages against official sources. It gives cited …

Java 25 Removes SecurityManager: What to Fix

Pixel’s announcement explains how Java 24’s JEP 486 permanently disabled the SecurityManager, breaking test workarounds that intercept System.exit. It recommends returning exit codes or throwing …