Have you ever wondered how emails work, how email finds its way from your computer to another computer thousands of miles away? It’s a fascinating system which handles over 210 billion emails every day and in this article we’ll explore exactly how emails work. People often do not even spare a thought for how emails work until they themselves run into a problem.
Email Predates The Internet By 30 Years
The Internet didn’t create email, but email helped create the Internet. Many of the curious ways emails work reflect email’s historic roots as a way for two users on the same computer to exchange messages. Today, emailing someone on the same computer as you seems ridiculous—but before the microcomputer revolution of the late 1980s, many computers and minicomputers supported hundreds or thousands of simultaneous users.
To send an email, a user of one of these large computers needed only indicate which username should receive the message. As computer science advanced, people began to connect computers together using primitive networking equipment. One computer scientist, Ray Tomlinson, connected two computers in 1971 and sent the first networked email using the now-familiar @ sign to indicate that the recipient was on a different computer. This is an amazing fact when learning how emails work. We would never even think of how it all started!
How Emails Work Today
By the time the Internet grew out of older networking standards, network email was well-established. It would still be almost 10 years before the Web was created, making email (and the related USENET) the main attraction of the Internet. For this reason, email is deeply entrenched in the core infrastructure of the Internet.
Email can be divided into two parts: the email format and the network protocols. Let’s start with the email format, which was officially defined in 1982 by by RFC 822. The basic format of email is very simple: all email is a text file containing two blocks of text. The top block of text is called the header; the bottom block is called the body. Separating the two blocks is a simple empty line.
RFC defines several common fields in the header that you’re familiar with: From, To, Cc, Bcc, Date, and Subject, as well as a few you might not see so often. The body of an email can contain almost anything, especially in modern email systems which support non-Latin characters.
Many email programs, including Thunderbird and GMail, let you see the raw format of email you’ve received. You will probably find it informative to open a raw email as you follow along with the rest of this article.
How Emails Work To Send Email
The text format used by email isn’t complicated, and in the old days, people used to compose emails by hand in text editors—I’ve done it on Linux servers which lacked a proper email program. But most people prefer to use an email program which builds the email for them and then sends it to a server on the Internet.
All email today gets sent using the Simple Mail Transport Protocol (SMTP), which truly is quite simple. When your computer wants to send email, it opens a connection to your Internet Service Provider’s (ISP’s) mail server and starts a conversation. Here’s an actual transcript of me sending email to myself using SMTP. Lines starting with numbers are from the server, everything else I typed:
220 mail.dtrt.org ESMTP Exim 4.72 Tue, 08 Mar 2011 00:25:59 -0500 HELO localhost 250 mail.dtrt.org Hello localhost [220.127.116.11] MAIL FROM:<firstname.lastname@example.org> 250 OK RCPT TO:<email@example.com> 250 Accepted DATA 354 Enter message, ending with "." on a line by itself From: "David A. Harding" <firstname.lastname@example.org> To: Me <email@example.com> Date: Tue, 08 Mar 2011 00:26:18 -0500 Subject: Have You Read Tips4PC Lately? Have you read Tips4PC.com lately? They have some great articles.
-Dave . 250 OK id=1PwpQC-0004qc-Tn QUIT 221 mail.dtrt.org closing connection
You don’t need any fancy software to start a conversation with your mail server—Windows Vista and Windows 7 come with a telnet command identical to the one I used to have the above conversation. If you install telnet, connect to port 25 of the mail server given to you by your ISP, and type all of the lines in the transcript above that don’t start with a number. (But change my email address to your email address.)
What you see above is exactly what’s going on behind the scenes as you upload your email to your server in Outlook or Thunderbird—but what happens after the server gets your email?
How Emails Work On The Server And Beyond
The technical name of the server which receives your email is Smarthost. It’s “smart” because it knows how to deliver email, whereas your typical computer doesn’t. The smarthost reads the RCPT TO field indicated in the SMTP conversation and looks at what follows the @ symbol—this is the mail domain name. For example, my email domain name is dtrt.org.
After determining the domain name, the smarthost runs a special Domain Name System (DNS) query on the domain. This is similar to how your Web browser runs a DNS query when you type google.com into your browser, but the smarthost isn’t looking for the IP address of the site’s webserver, it’s looking for the site’s mail server—the webserver and mail server can be on different computers with different IP addresses. Mail server records are stored in MX fields—if you’ve ever bought a domain name, you may be familiar with these fields.
After finding the IP address for the domain name, the smarthost opens a new SMTP connection to that IP address. Just as in the transcript above, it identifies itself with the HELO command, tells the new mail server who the mail is from and who it’s going to, and then includes the text of the email before quitting.
All of this might sound a little complicated but this is how emails work—why can’t you just connect to the destination mail server yourself? The answer is that you can—but most ISPs block direct SMTP connections from personal computer IP addresses in case those computers have been infected by spam-sending viruses. So even if you run a smarthost, you probably won’t be able to use it.
How Emails Work Its Way To Its Destination
After the smarthost delivers mail to the destination mail server, the email still needs to be delivered to the intended user. If the destination is a webmail account, the the email is simply placed in the appropriate database. If the destination user downloads email using the Post Office Protocol (POP), the email is appended to a file containing emails for the user to download. If the user reads email over the Internet Message Access Protocol (IMAP), the the file is placed in a database, directory, or file, depending on which IMAP software is used.
The recipient doesn’t need to know how emails work—he or she needs only to open their email program or Web browser and start reading.
Learn more computer basics. (how emails work is not that basic though)