How does email work?

A lot happens when you hit "send."

  1. Email messages are composed using an email program (an email client).
  2. The email program assembles the email by combining the message content (the body) with the recipient, subject plus the date and time (the header).
  3. Email relies on a set of protocols to arrive at the correct destination.
  4. The email program (the email client) comes in two forms, a web based version like gMail where users must login through their browser to access their emails, or a client based version such as Outlook where users install software to access emails from their local computer.

If you use a computer regularly, it’s pretty likely you send and receive countless emails each day. Emails from clients, subscriptions to newsletters, messages from friends and family and not tomention spammers. Most internet users don’t know these emails are sent or arrive in their inbox, and that’s okay. From the typical email user's standpoint, it seems simple. We think of email as something that pops up when messages come through to our mail client (Thunderbird, Yahoo, Outlook, etc.).

When you send an email to your Mom, you type her email address, compose, hit send and their reply comes back to your email client. To some extent, this is true, but, there’s much more to it than that. How emails are structured and transmitted is a complex process, and with the help of relatable analogies, we can explain the entire process in an easy to absorb manner.

As simple as it seems, email relies on a different set of protocols than those used to access website content. To order, store and access emails relies on a set of protocols that’s different from what the rest of the internet depends on.

For most email users, it’s not necessary to understand how email works to use it. If you’re interested in how these messages ping into your inbox, stick with us. This short introduction has been developed to help understand the basic principles of email. It’s surprising how close the process of emailing is to the old-fashioned written format. If you’ve ever written a formal letter, you'll have no trouble getting your head around how email works.


What is email

Email was actually invented before the publicly accessible internet as we know it. Email was conceived as a means for computers to communicate with one another. From the early 1960s the computer network ARPANET, a computer communications network created by United States Department of Defense developed a system of email transfers that relied upon the now familiar "@" sign. Ray Tomlinson, the man widely acknowledged to have masterminded email as we know it chose the @ symbol deliberately.

According to Tomlinson "The primary reason was that it made sense. The @ sign didn't appear in names so there would be no ambiguity about where the separation between login name and hostname occurred. (Raytheon BBN Technologies, 11 February, 2011).

The addition of the @ symbol allowed messages to target certain users on certain machines and showed that it wasn’t sent to a local host. This separation of usernames from machine names works similar to how websites are allocated human-readable names instead of IP addresses. This resulted in email addresses taking the format username@host, and later, loginname@host.domain once the domain name system (DNS) was developed.

Emails are routed to user accounts via several computer servers. They route the message to their final destination and store them so that users can pick them up and send them once they connect to the email infrastructure. Email can be accessed through an email client or a web interface (more about these later). When you click send, the message is transmitted from your computer to the server associated with the recipient’s address. This process typically takes places via several other servers before the message gets to its intended recipient's mailbox.

Electronic mailboxes are central to how emails work for the end user. A mailbox is where electronic mailboxes are stored, and when a user receives an email, the mail system automatically puts it in their mailbox. The mailbox makes emails user-friendly. They separate emails into folders; inbox, outbox, spam, etc. and allow users to scan mail, copy, delete, or forward it to another user. But what happens before it hits the mailbox?


Email Servers (SMTP and MTA)

Unlike your physical mailbox where one service, the post office, handles all of your mail, with email, your incoming and outgoing mail is handled differently. There’s two types of servers. The Simple Mail Transfer Protocol (SMTP), which an email delivery protocol. It’s used to send mail over the internet. SMTP contains information regarding the transmission details of an email message and is specifically used for outgoing mail. A Mail Transfer Agent (MTA) is a server program that uses SMTP to deliver emails.

There are two types of MTA, a client-based MTA which involves installing software to access emails (such as Outlook), and a web-based MTA which is accessed through a web browser (gMail for example). Anyone can use their computer to run an MTA. It’s fairly easy, and an MTA will handle incoming mail well. Running your own MTA to deliver a high-volume of bulk-emails while maintaining a good level of deliverability will get complicated. There are standards and conventions that need to be followed. Failure to adhere to them will hurt your ability to deliver mail reliably. A shorter, more straightforward route would be configuring your clients to use your ISP’s SMTP server instead of setting up and running your own.

Sending mail is a different story. SMTP relies on the TCP port 25. When an email is sent, Port 25 is typically used to route the message to a local computer that’s designated with handling e-mail by a network operator. This email server is pre-approved by the email host, and handles incoming email messages and sends on messages. The problem with Port 25 is that it gets clogged with spam emails if computers on the same network become infected with malicious software or a virus. For this reason, most anti-spam guidelines propose blocking port 25.

Unless a user hosts their own email, they can’t send mail themselves since most internet service providers block Port 25 and SMTP servers require static IP addresses to do their job. Blocking Port 25 blocking allows ISPs to eliminate any spam that’s sent out through their networks. There is a snag, blocking this port tends to punish the innocent that have a need to send through email servers other than those belonging to their ISP.

The reason for blocking anyone and everyone from sending emails themselves is to keep the internet in some working condition. Consider the massive amounts of spam that would be eating away at our collective bandwidth. Indeed, software that transfers electronic mail messages should be configured to filter it out, but if it weren’t, there would be no joy in opening that mailbox. The main thing to understand is that both an MTA and an SMTP server are needed to use email, as each is specialized for what it does.


How Email Works

The moment an email is sent, a message is routed from server to server via the Simple Mail Transfer Protocol until it makes its way to from the client to the email recipients email server.

  1. Sending an email is just like sending a letter to a friend. Let’s say isobel@example.com sends an email to their friend simon@example.com. The email gets sent first to an outgoing mail server (SMTP) whose job, just like that of the post office, is to transport emails. The SMTP first checks the postage address to figure out where to send the mail. Unfortunately, the SMTP doesn’t understand how to read the domain name (just like the mailman consults a map since he doesn’t know every street name by memory). The SMTP needs a computer friendly IP address to locate and deliver the message to the recipient. To locate the IP, the SMTP contacts the DNS server (the internets phone book) to translate the recipients email address, simon@example.com to an IP address like "45.789.56.89". Once the associated IP has been found, it can determine if that domain has any mail exchanges servers (MX) which detail any additional information about where the message should be routed to. This is just like checking if the recipient uses a mailbox or a PO box to receive their mail in real life.

  2. By now, the SMTP has all the necessary information about the recipient to send the message from its server on to the email recipients MTA server.

  3. The MTA decides where exactly to put the mail, whether the recipient is using a client that works via POP or via the IMAP protocol. The recipient will then receive a new email notification and the mail will wait in the mailbox until it is fetched.

So there you have it, email transmission works in virtually the same way as sending real mail. Once an email is sent, the mail server puts it in an envelope (the SMTP protocol connection). Let’s take a lot at how email is sent from a strictly technical standpoint.

  • Once an email is composed and the send button is clicked, the message is sent to the Mail Transfer Agent (MTA). This communication is done via the Simple Mail Transfer Protocol (SMTP).

  • The SMTP queries the Domain Name System (DNS) to find the address of the recipient. This is done with the help of a Mail eXchanger (MX) record. The MX record is a resource record which specifies the mail server of a domain name. Once located, the SMTP server will send the message to that server.

  • The next step involves transferring the message between mail servers. The SMTP has done its job of routing the message to the destination server. The message is now in the recipient’s mail server (MTA). The receiving server will store the message and make it available to the recipient who can access it via web, POP, or IMAP protocols.

Email Protocols

Mail Transfer Agent’s (MTAs) communicate with each other over the internet using SMTP protocol (SMTP servers). The recipient’s MTA then forwards the email on to the incoming mail server (MDA, mail delivery agent) which is tasked with storing the mail until the user accepts it. To retrieve email on an MDA, a supporting protocol must be used. There are two main protocols, POP3 and IMAP. You might recognize these two acronyms since incoming mail servers are called either POP servers, or IMAP servers depending on which protocol they use.

Pop vs. IMAP

POP stands for Post Office Protocol. This piece of software is used for retrieving email. Just like a visit to a post office you can drop in, pick up your mail and leave. POP3 gives an email user access to their emails stored in their user account on that server. You don’t need to stay online for the emails to come through. You just need to leave a copy of an email on the server to access it.

POP does have some drawbacks; namely, information transmitted through POP travels one way. This means that once an email is downloaded to a client, the client takes charge of sorting through the different status flags (e.g. sent, deleted or answered). This was fine when the internet was young, before smartphones, tablets and the like. People accessed their mail from a single location. Nowadays, it’s more likely that you access emails from many places; thunderbird at home, the mail app on your cell phone or a web interface when you are at work for example. With POP, you would have to sort through the information over each different device, that is assuming you’ve saved a copy of each email on the server, to begin with.

IMAP (Internet Message Access Protocol) is a bit smarter about how it coordinates emails. IMAP clients have two-way communication with their servers. The IMAP protocol saves a copy of every message on the server so that unlike with POP, multiple clients can access them. It’s completely synchronized. With IMAP, when you check an email on your tablet, it will be marked as read when you check your inbox on your phone. This happens because the status of the email is updated with all other clients during the server interaction.

Back to the post office analogy. IMAP is just like when your mail is categorized and stored at the post office for you and redelivers it when you are at home, at work, or pick it up there in person. You can keep a properly marked archive on your home client as well as on your mail server. IMAP has an offline mode where any changes are synced with the server the next time you’re online. You may configure IMAP mail servers to fetch mail from POP inboxes, too, which works well if you’re seeking to consolidate. Of course, given that IMAP works with the "cloud" best, servers get entry too, and storage can be problems. Thankfully, storage space and bandwidth isn’t as pricey as it once was, but this will truly be a change-off for a few humans.


How Email is Received

Let’s now take a look at how email is received. No surprises here — we’ll revert straight back to our mail carrier analogy. How would an envelope be delivered to the recipient on the front of the envelope? The postal service will find the most logical route to the recipient.

First, the carrier will look up the route to the recipient's address. He makes his way to the recipient's address but can’t locate a mailbox so knocks on the door. Someone opens the door, and the postman asks if that person wants letter. Naturally, they will want to know where the letter was sent from, who sent it and who it’s for. Reading the address on the back of the envelope, the mailman can confirm these details. Even if the person who opened the door isn’t who the letter is addressed to, they can accept post to the addressee and sign the mail mans receipt.

The electronic version of events is handled similarly"

  • The mail server located the recipients server, but since the recipient’s server won’t accept any mails that comes it’s way, it asks who sent the email.

  • The sending server gives the recipient server information on who the sender is by querying the envelope. Acknowledging the email is from a legitimate source (not spam, etc), the recipient server says "sure I understand that Namecheap exists, and from that sending address".

  • Satisfied the address is correct, the recipient server asks who the envelope is addressed to and whether the recipient server will accept the details on the envelope. This is how envelope data is treated. The sending server will now forward the contents of the email contained in the envelope. Once the email has been received, the recipient server gives the mail server a receipt.

Types of MUA

Retrieving email is tasked by a software programme called a Mail User Agent (MUA). There are two types of MUA and these are classed depending on how emails are accessed, via installed software (email client) or through in browser (webmail).

  1. When an MUA is a program is installed on a user’s system it’s called an email client. To use an email client MUA such as Microsoft Outlook, Mozilla Thunderbird, Lotus Notes for example users install the MUA program to their computer. This program is used to download and store email message to their computer. With a client MUA, emails can be read and written offline.

  2. When email is accessed online, it’s called webmail. Web based MUAs such as Yahoo, gMail and Hotmail store messages on their own mail servers, and can only be accessed through a web page. The main advantage of webmail is the ability to send and receive mail from a web browser, anywhere. The main disadvantage to using a web based application is the need to be connected to the internet to use it.


The Journey of an Email

Let’s break down how an email is transmitted. Like most Internet data, emails travel across the internet as a stream of packets using the internet’s TCP/IP protocol. This process can be broken down into three steps:


How are Emails Structured?

It might have been a while, but consider how you’d formulate a formal letter you’d take to your mail office or drop in a mailbox. You start with taking pen to paper and begin with writing your name and address on the right-hand side. On the left-hand side, you write the name and address of the intended recipient. Once you’ve written the body of the letter, you place it in an envelope. This is sealed, and the intended recipient's address is written on the front so that the sorting office knows where the letter will be sent. Just in case there is a problem finding the recipient, the sender's address is written on the back so that the post office knows who the letter should be sent back to.

As technical as email might sound, the letter analogy is the same as the way emails are structured. Emails are composed in a mail client (comparable to pen and paper), this is known as MIME data (multipurpose internet mail extensions). The mail server puts the email into an envelope which includes the recipient and sender’s addresses (this is called envelope data). Email users won’t come across the envelope since it’s part of an internal process to route an email.


Email Envelope, Body and Header

An email is constructed with three parts:

  1. The envelope that we’ve just mentioned. This is separate from the body and header. Next is the body (that contains content of the message). Email clients separate an email header and the body (the content text).

  2. The body is distinct from the header; it contains everything within the message including images, text and any other data (such as attachments).

  3. The header which is arguably the most interesting part of an email’s DNA. The header always precedes the body text. This is logical, When you receive an email, it’s often the header that’s scanned first before the email is opened.

The header includes the mandatory information including the sender, recipient and date. Other header lines such as subject and cc are optional. Although only mandatory headers appear to the user, the header includes other important details such as the route the email took as it was transferred from one computer to another. We’ve mentioned the job of Mail Transfer Agents (MTAs). When an email is forwarded by an MTA, it is time stamped. You’ll notice that some email, that had multiple destinations since the origination of the email, have several received headers. Most of this extra information is hidden inside the email. When viewed in their entirety they look something like this:

There’s a lot to digest here, but we hope this piece has given you some understanding of just how much goes into the seemingly-simple act of sending an email.

You may also like

Email Hosting →

Need help? We're always here for you.

× Close