"You see, wire telegraph is a kind of a very, very long cat. You pull his tail in New York and his head is meowing in Los Angeles. Do you understand this? And radio operates exactly the same way: you send signals here, they receive them there. The only difference is that there is no cat."
-- Albert Einstein, explaining radio.
Email, like Telephones, the Internet, Power Lines, Credit Card Terminals, ATMs, etc. have become so much part of our daily lives that we just accept it without really thinking about it. You click "New," put some data into a form, then click "Send." In a couple of seconds (minutes if your mail servers are suffering a spam blizzard), your LOLCAT Email has zipped from one end of the Internet to the other (This proves that, unlike radio, Email does have a cat). Do we marvel at this paragon of technology? Not really. I generally grumble at the mixed blessing that has brought me spam.
A while back, I made the mistake of reading the Wikipedia article on the Power Grid. I was amazed at the mechanics of the system that allows a handful of uranium melting itself into slag in Glen Rose, Texas to shove electrons across a couple hundred miles of copper, through a handful of coils... all to be stopped by a little switch in my wall before they could excite the gasses in my Compact Fluorescent light bulbs. For two weeks after that, I was a road hazard. In the middle of my commute, I'd glance at my right hand mirror, gaze out my side window, and think "Hey! I didn't know they were running two phase power out here!" I must say that I couldn't have been a more dangerous driver during those two weeks if I was dryping.
My latest project at SoftLayer (WHOIS management for ARIN... look in the portal under SWIP) had me doing research on Email (as all transactions are conducted through Email).
Like David Bowman staring into the black monolith at the end of 2001, I was struck by the simplicity and beauty of the Email system!
Let’s tag along with an Email message, so you can see just how cool this is.
Bob is currently taking a vacation in Glen Rose, Texas (taking the tour of the Nuclear Power Plant). Sitting in the lobby of the Visitor's Center (thinking about this giant reactor being at the beck and call of his little switch), he has a firm wish that Alice could come see this. He's a cheapskate, though, (that’s why he’s at a local power plant instead of, say, Disneyworld) so he's not going to waste money on a Power Plant Postcard and stamp at the gift shop. No sir, he opens up his blackberry and sends a short Email to Alice ("Wish you were here!"). A few seconds later, Alice's Email client pops up an alert that she's received an Email from Bob. The Email itself is simply a block of text… really! No magic going on here! Here's what the Email looks like:
From: email@example.com To: firstname.lastname@example.org Date: Wed, 10 Oct 2007 12:54:08 -0400 (EDT) Received: From EXAMPLE.NET by EXAMPLE.COM with SMTP Wed 10 Oct 2007, 12:55:00 -0400 (EDT) Wish you were here! --- Bob Sending to Alice for over 30 years.
Simple, huh? To help visualize this transaction, Figure 1 shows a “RFC 2822 Compliant Post Card:”
Bob opens up his Email client, and writes "Wish you were here!" in the message area. He then adds his signature, and writes in the subject. The Email client adds headers to the address area of the Email (From, To, and Date), then drops the Email into Bob's local Email server (EXAMPLE.NET).
The Email server at EXAMPLE.NET looks at the address section of the Email and notices where it is to be sent to Alice (who has an Email box at EXAMPLE.COM), and opens up a SMTP (Simple Mail Transfer Protocol) connection to Alice's mail server. It then sends the message and moves on.
Alice's Email server puts a “postmark” header on the Email (the Received header) and drops a copy of the entire text block into Alice’s Email box.
Alice opens up her Email client, which then downloads all the text files from her Email box. It reads the From header and tells Alice that she has an Email from email@example.com
That’s it! Simple, huh?!?
If Bob's Email server can't send the mail directly to Alice Email server, it can send the Email through a relay server. This server adds its own "Received header" to the Email. If you look at the headers of any Email you've received (spam is not only a good source of vitamin Sodium Nitrate, but also an excellent resource for Email headers), you can see every single server your Email passed through. It’s like those neat stickers customs officials stick to your luggage as an apology for cracking your locks when you fly internationally.
That's all there is to it! A simple block of text, passed off to an Email server. And the actual protocol is just as simple. Here's what the communication between Bob's Email server and Alice's Email server looks like (modified from the example on Wikipedia's SMTP article):
Bob’s server connects to Alice’s and identifies itself:
ALICE: 220 smtp.example.com ESMTP Postfix BOB: HELO example.net ALICE: 250 Hello example.net
Bob's server then tells the receiving server about the Email:
BOB: MAIL FROM:<firstname.lastname@example.org> ALICE: 250 Ok BOB: RCPT TO:<email@example.com> ALICE: 250 Ok
Bob's server then tells Alice's that it's ready to send the real message:
BOB: DATA ALICE: 354 End data with <CR><LF>.<CR><LF>
Next follows the RFC Compliant Email message from above, ending the data with a ".", which tells Alice's server that Bob’s message is complete:
BOB: From: firstname.lastname@example.org BOB: To: email@example.com BOB: Date: Wed, 10 Oct 2007 12:54:08 -0400 (EDT) BOB: Received: From EXAMPLE.NET BOB: by EXAMPLE.COM with SMTP BOB: Wed 10 Oct 2007, BOB: 12:55:00 -0400 (EDT) BOB: BOB: Wish you were here! BOB: BOB: --- BOB: Bob BOB: Sending to Alice for over BOB: 30 years. BOB: .
Alice's server lets Bob's know that the message is queued to go, and Bob's server signs off:
ALICE: 250 Ok: queued as 12345 BOB: QUIT ALICE: 221 Bye
I marvel at this technology. Every Email in the world is transmitted by this simple protocol. The whole of electronic communication takes place by handing small blocks of text from one Email server to another, until it finally makes its way to the recipient's inbox. That's all! No magic potions, no hocus pocus, no tying messages to carrier pigeons or pulling cat tails.
Not only this, but your message is flying through a blizzard of spam. Because the protocol is so simple, people build simple tools that blast out millions of messages at a time, flying all over the Internet. But the awesomeness of this just makes Email that much more awe inspiring. Email has been running, nearly uninterrupted (as a whole) for DECADES under the most concerted distributed denial of service attack of all time.
And STILL your Email gets to its destination. Benjamin Franklin would be proud.
Think of this the next time you forward the latest list of funny jokes to everyone on your Email list. This incredibly simple protocol will make sure that your vital Email gets to every recipient listed! "Neither snow, nor rain, nor heat, nor gloom of night stays these couriers from the swift completion of their appointed rounds..."