How They Work: How Emails Work – Part II

There are lots of Web servers, FTP servers, telnet servers and e-mail servers running on millions of machines on the Internet right now.These applications run all the time on the server machine and they listen to specific ports, waiting for people or programs to attach to the port.

Saturday, October 22, 2011

There are lots of Web servers, FTP servers, telnet servers and e-mail servers running on millions of machines on the Internet right now.

These applications run all the time on the server machine and they listen to specific ports, waiting for people or programs to attach to the port.

The simplest possible e-mail server would work something like this:-  It would have a list of e-mail accounts, with one account for each person who can receive
e-mail on the server.

My account name might be eddbash, your account might be readthis, and so on.  It would have a text file for each account in the list.So, the server would have a text file in its directory named EDDBASH.TXT, another named READTHIS.TXT, and so on. 

If someone wanted to send me a message, the
person would compose a text message ("Eddie, Can we have lunch on Sunday? Reader”) in an e-mail client, and indicate that the message should go to eddbash.

When the person presses the Send button, the e-mail client would connect to the e-mail server and pass to the server the name of the recipient (eddbash), the
name of the sender (readthis) and the body of the message.

The server would format those pieces of information and append them to the bottom of the EDDBASH.TXT file. The entry in the file might look like this:- From: readthis To: eddbash Eddie, Can we have lunch on Sunday? Readthis. 

There may be several other pieces of information that the server might save into the file, like the time and date of receipt and a subject line; but overall, you can see how
simple the process is.

Of course, there are More Complex Servers than our example above. As other people sent mail to eddbash, the server would simply append those messages to the
bottom of the file in the order that they arrived.

The text file would accumulate a series of five or 10 messages, and eventually I would log in to read
them. When I wanted to look at my e-mail, my e-mail client would connect to the server machine.

In the simplest possible system, it would; ask the server to
send a copy of the EDDBASH.TXT file; ask the server to erase and reset the EDDBASH.TXT file; save the EDDBASH.TXT file on my local machine; parse the file
into the separate messages (using the word "From:” as the separator) and show me all of the message headers in a list.

When I double-click on a message header, it would find that message in the text file and show me its body.As you can see, this is a very simple system. Surprisingly, the real e-mail system that you use every day isn’t much more complicated than this. 

The Real E-mail System works more or less as in above.  For the vast majority of people right now, the real e-mail system consists of two different servers
running on a server machine.

One is called the SMTP server, where SMTP (Simple Mail Transfer Protocol). The SMTP server handles outgoing mail. The other is either a POP3 server or an IMAP server, both of which handle incoming mail.

POP stands for Post Office Protocol, and IMAP stands for Internet Mail Access Protocol. A typical e-mail server looks like this; The SMTP server listens on well-known port number 25, POP3 listens on port 110 and IMAP uses port 143.  

The SMTP Server - Whenever you send a piece of e-mail, your e-mail client interacts with the SMTP server to handle the sending.

The SMTP server on your host may have conversations with other SMTP servers to deliver the e-mail. Let’s assume that I want to send a piece of e-mail. My e-mail ID is eddbash, and I have my account on afrowebs.com.

I want to send e-mail to readthis@rwahoo.com. I am using a stand-alone e-mail client like Outlook. When I set up my account at afrowebs.com, I tell Outlook the name of the mail server mail.afrowebs.com. When I compose a message and press the Send button, this is what happens:

Outlook connects to the SMTP server at mail.afrowebs.com using port 25.

Outlook E has a conversation with the SMTP server, telling the SMTP server the address of the sender and the address of the recipient, as well as the body of the message.

The SMTP server takes the "to” address (readthis@rwahoo.com) and breaks it into two parts: the recipient name (readthis) and the domain name (rwahoo.com).

If the "to” address had been another user at afrowebs.com, the SMTP server would simply hand the message to the POP3 server for afrowebs.com (using a delivery agent).

Since the recipient is at another domain, SMTP needs to communicate with that domain. The SMTP server has a conversation with a Domain Name Server,
or DNS .

It says, "Can you give me the IP address of the SMTP server for rwahoo.com?” The DNS replies with the one or more IP addresses for the SMTP server(s) that Rwahoo operates. The SMTP server at afrowebs.com connects with the SMTP server at Rwahoo using port 25.

 It has the same simple text conversation that my e-mail client had with the SMTP server for afrowebs.com, and gives the message to the Rwahoo server.

(To be cont’d)

eddie@afrowebs.com