Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway. — Andrew Tanenbaum, 1989.
The quote above was used regarding a different topic, but given the complexity of modern digital communication, considering a “station wagon” is sometimes a viable choice.
Email is a method of exchanging messages using electronic devices
Email is based on store-and-forward communications technique, which consists of an intermediate (in this case, the email server) that receives information, stores it, and only later sends it to the destination. In the world of email communication, this logic of this model is what enable us to send an email to users who are currently offline and allows them to receive it, whenever they’re online.
And the beauty in all of this? By using an electronic address, you can pass this content to whoever you want. Using a simple address format – email@example.com – you can reach any electronic recipient, taking advantage of the address resolution protocol which allows users to surf the web using English addresses.
In this blog, we will cover the basic principles that allow us to send emails freely across the globe. We will start with what an email message is and explain what is actually being transferred.
Originally, the information sent and received in email communication was simple text messages in ASCII.
Today, email messages can carry much more than just English text. They can be written in different languages (with several different character sets), they can include links, and they have the ability to carry files (known as “email attachments”).
To allow this, in modern email services, the information sent and received takes the form of some version of Multipurpose Internet Mail Extensions (MIME).
MIME is essentially an Internet Standard for decoding and encoding complex messages in digital communication. It is a normative specification, used in other types of communication besides email, such as Post Office Protocol (POP) which is very common in apps, or the Internet Message Access Protocol (IMAP).
These standards guarantee the existence of the key features that allow encoding/decoding and/or validation of the information sent in a message, and in the context of this discussion – of an email message.
The Email Components:
Each email is comprised of two key components:
- The “Header” – holds information about the message required by the SMTP protocol.
- The “Body” – contains the actual content of the message (the text and any attachments). The body can be in the format of plain text, html or both.
Now that we understand what is actually being sent, we can have a deeper look on how messages are delivered from a sender to a designated recipient.
Similarly to regular, physical email exchange, in order to send a message one must have an “envelope” to transfer the message between servers.
The same way MIME is used to determine how to decode/encode the message itself, there is a protocol called “Simple Mail Transfer Protocol (SMTP)” to transfer the message. This is another internet standard that defines how a message envelope should look and how to handle such incoming envelopes.
SMTP was Introduced in RFC (Request For Comment) 822 as ARPANET text messaging, and made obsolete by RFC 5321 . It has been updated many times since. Today, SMTP is an Internet Standard for mail transmission, defining how a message envelope should look and how to transfer it from one server to another.
It is important to note that SMTP was created with routing support, allowing it to be the backbone of the modern, complex, and scalable email systems. Theemail is received using SMTP by an agent which can pass the email to another agent using SMTP, each such transfer of the email, is referred to as hop.
SMTP defines different entities which are involved in modern email communication. Any of these entities serve as their own SMTP server. As such, they each create a record of their actions. Each operating according to the frame set by the protocol and according to the source and destination as written by the envelope of the original composer of the email. There are three key entities related to email transfer:
- MUA (Mail User Agent): the server which created the original message envelope and starts the transfer sequence. SMTP also defines the MSA – the mail submission agent – but with modern email, the user will submit the email through an online portal which runs an SMTP server as well, acting as both the MUA and the MSA.
- ● MTA (Mail Transfer Agent): a server which receives the message and transfers it to the next destination.
- ● MDA (Mail Delivery Agent): the last SMTP server which receives the message, stores the message in the user’s inbox
Modern Email typically goes through three phases:
- The sender’s internal hops: a user creates the desired email on his/her computer or phone by going online and connecting to a server, which mostly serves as an MUA and an MTA. The message can make zero or more hops through MTAs (large email providers often have different routing configurations to handle the varying load of email traffic and security) until it reaches the outbound gateway, which is the MTA responsible for the external hop.
- External hop: the outbound gateway MTA will then use DNS to check the MX (mail exchanger) record. This is attributed to the target’s mailbox mentioned in the mandatory SMTP headers. The MX record contains the address of the server which receives the email on behalf of the address found in the header. Then, the boundary MTA will transfer the message using SMTP to that server.
- The receiver’s internal hops: the server mentioned in the MX record is referred to as the “inbound gateway” for the receiving user. This is normally the point where higher levels of message integrity checks are performed, such as SPAM, which are not part of the SMTP protocol. It can then make zero or more hops through MTAs until it reaches the receiving user’s mailbox (again, depending on the receiver’s setup. In this case, one will almost always see at least one hop which serves as the front gate to the network and is often capable of handling huge traffic).
As part of SMTP, each hop the email makes adds its own mark, creating a track of all hops through which the mail was transferred. The protocol forces the servers to add mandatory headers (e.g. “Received” header, see example below) which provide identification of the agents involved in each hop, as well as keeping the IP of the SMTP server sending and receiving the email.
Received: from [server address received in the smtp transaction] ([server address received in the tcp connection] [ip received from tcp connection])
Mon, 15 Jul 2019 10:12:13 +0000 (UTC)
Also known as the “trace” header, following up on these headers one can obtain the entire path of the message which landed in his/her inbox, and the IP of each server involved in the email transaction.
This article will be followed by a new post on more advanced email-related protocols, so stay tuned.
Thanks for reading. You are most welcome to spread this knowledge.
Oded Kalev, Software Developer at Perception-Point.