How Email is Sent

Email is an old-as-time standard. After dozens of published documents that altogether document the format, transmission, and access of email through email infrastructure, the email standard has been adopted across all age groups as the most professional and standard form of Internet communication today.

They were officially known as ARPA Internet Text Messages, later called Electronic Mail Messages, and now colloquially known as email.

Nearly all email today is sent and received either using a website interface such as Gmail or through one of several email clients. Email clients range from full-blown suites like Microsoft Office Outlook to mobile platforms on the iPhone. The program through which a human being sends and receives email is known as a Mail User Agent (MUA).

MUA’s connect to SMTP servers when sending email (outbound email). SMTP (Simple Mail Transfer Protocol) operators include Gmail and Hotmail as well as enterprise-level SMTP servers for schools and corporations or website-specific SMTP servers like the RogerHub SMTP server that I personally use.

The Mail User Agent delivers a message to an SMTP server using the SMTP protocol. It looks something like the following:

helo example
mail from: Person rcpt to: Example
data
To: example@gmail.com
From: person@example.com
Subject: Greetings!
Hello there.[press the return key]
[press the return key again]
.[press the return key]
quit

Emails are split into two general sections: the headers and the body. The headers are at the top and identify the sender, recipient, subject, message thread, as well as a host of other things such as antivirus information, domain authenticity, and the path an email takes before it reaches its destination. Headers are separated from an email body by an empty line.

An email can also specify multiple parts in its message body. Some of the parts can be different formats for the same message, such as an HTML-based format and a plain text format. Others include attachments that are encoded and hooked onto the email.

To recap:

The two computers (MUA and SMTP) identify themselves and then the message is transmitted. Typically, this communication is wrapped in a secure, encrypted tunnel provided by TLS or SSL. Additionally, a MUA needs to identify itself with credentials so that the SMTP server can verify who the sender is.

SMTP traffic is delivered over TCP port 25 typically. After receiving the message from the MUA, the SMTP server uses the same SMTP protocol to transmit the email to another SMTP server that will continue to pass it on until it reaches its destination.

Certain SMTP servers are configured to break the path of transmission for certain destination emails. For example, the RogerHub SMTP server is configured to not transmit any email destined for a @rogerhub.com email address. The final SMTP server keeps the email and stores it.

To access email, some people use a web client such as Gmail which pulls email directly. Others use a email client that must communicate with a server in order to access email.

Email clients have two protocols to access email from an email server: POP3 and IMAP. These two protocols define rules about how email clients can access email messages. The primary difference between the two is that IMAP allows a user to synchronize email between client and server, enabling things such as sorting by folder, deleting, and reordering.

How does a SMTP Server know where to connect in order to deliver an email? Each domain (rogerhub.com) has a series of MX (mail exchange) servers listed in its DNS (domain name service) records. A SMTP server must first look up these MX servers, and tries with the SMTP protocol to connect to each one until it can successfully deliver a message. If none of them work, the SMTP server keeps the message and retries 4 hours later.

If an SMTP server ultimately fails in delivering the message, it returns it to the sender with a error message from the SMTP Daemon.

Setting up and configuring an email system for your own personal use involves setting up these MX records, an SMTP server to receive and send mail, authentication and encryption for this server, and possibly a POP3/IMAP server to communicate mail.

I hope you never have to go through this process as I did, because it really is a headache.