Understanding E-Mail

E-mail is something that most people take for granted without ever really understanding how it works. If you want to write applications that send and receive e-mail messages, it is essential to have some understanding of a typical e-mail system environment.

E-mail messages are sent on a client/server basis, but one that is different to that used for Web pages. Figure 11.1 shows a typical e-mail delivery process. As you can see, both the sender and recipient act as clients to e-mail servers. The sender creates a message and this forwards to an e-mail server. The server then uses the Simple Mail Transfer Protocol (SMTP) to send the message across the Internet to the recipient's mail box on another e-mail server. The receiver then uses a retrieval protocol, such as Post Office Protocol (POP3) or Internet Message Access Protocol (IMAP), to retrieve the message from their e-mail server.

Figure 11.1. A simple e-mail architecture.


The actual e-mail message itself consists of two sections—the header and the body. Mail headers are name-value pairs that define certain attributes of a particular message, such as who the sent the message and when the message was sent. The body is the actual e-mail message. Originally, the message body could only contain ASCII-based text. The standard 128-character ASCII set and the inability to embed multimedia objects or attach files meant that e-mail was restrictive. Over the years, there have been a number of ways to expand the functionality of e-mail. Today, you can use the Multipurpose Internet Mail Extensions (MIME) format to construct and send content-rich e-mail messages that are not limited by the standard 128-character ASCII set. You will learn more about MIME in just a moment, but first, today's lesson will provide you with an overview of some the commonly used e-mail protocols.

SMTP

Simple Mail Transfer Protocol (SMTP) is the protocol that mail servers use to send messages to one another. SMTP communication occurs over TCP port 25 using a simple sequence of four-character client commands and three-digit server responses. It is unlikely that you will ever have to communicate using SMTP directly with a mail server, but it might interest you to see a typical conversation between a client and a mail server:

HELO madeupdomain.com
    250 Hello host127-0-0-1.anotherdomain.com [127.0.0.1]
MAIL FROM: [email protected]
    250 < [email protected] > is syntactically correct
RCPT TO: [email protected]
    250 < [email protected] > is syntactically correct
DATA
    354 Enter message, ending with "." on a line by itself
Hello World!
.
    250 OK id=1643UJ-00030Z-00
QUIT
    221 closing connection

You can see just how simple the protocol is. The client connects to the server and issues a HELO command and the server responds with a 250 (OK) response. The client then issues a MAIL FROM: command and a RCPT TO: command and, in both instances, the server replies with a 250 response. The client then issues a DATA command and sends a message. Finally, the server issues a 250 response and the client issues the QUIT command.

The important thing to note about SMTP is that it is not used to deliver a message directly to the recipient but, instead, delivers it the recipient's mail server. This mail server then forwards the message to the recipient's mail box—a file or other repository that is held on the server—and not the recipient's client machine.

Post Office Protocol 3 (POP3)

POP3 is a protocol that allows message recipients to retrieve e-mail messages stored in a mailbox on a mail server. The protocol operates on TCP port 110 and, like SMTP, uses a series of simple requests and responses. Unlike SMTP, users must provide authentication credentials (username and password) before they can download e-mail messages from their mail boxes.

Many e-mail clients use POP3, although the protocol allows quite limited server-side manipulation of messages. On the server, the user may list, delete, and retrieve e-mail messages from his or her mail box.

Internet Message Access Protocol (IMAP)

Like POP3, IMAP is an e-mail message retrieval protocol. Also like POP3, it works on a simple request-response model, but it does operate on a different TCP port—port 143. The biggest difference between the two protocols is that IMAP transfers a lot of client-side functionality to the server. For example, you can browse messages' subjects and sizes and senders' addresses before you decide to download the messages to your local machine. You can also create, delete, and manipulate folders on the server, and move messages between these folders.

Other Protocols

The three previously mentioned protocols are prevalent current e-mail systems, but there are other e-mail protocols. Some of these are previous versions of existing protocols. For example, some machines might still run POP2 servers. Other protocols are variations on those previously mentioned—for example, IMAP over SSL. Finally, there are a variety of protocols that provide either specialist functionality or different interpretations on the popular protocols. For example, the Network News Transport Protocol (NNTP) is the main protocol clients and servers use with Usenet newsgroups. If you want to learn more about this protocol, refer to Request for Comments (RFC) 997, which is available at http://www.rfc.net/rfc997.html.

Multipurpose Internet Mail Extensions (MIME)

The MIME format extends the capabilities of e-mail beyond the 128-character ASCII set to provide

  • Message bodies in character sets other than US-ASCII

  • Extensible formats for non-textual message bodies, such as images

  • Multipart message bodies (you'll learn about these later today)

  • Header information in character sets other than US-ASCII

  • Unlimited message body length

The MIME standard provides a standard way of encoding many different types of data, such as GIF images and MPEG videos. MIME defines additional message headers that a client can then use to unpack, decode, and interpret the data the message body contains. The message body may consist of several body parts including attachments. The “Creating Multi-Media E-mails” section of today's lesson explores MIME in more depth. You can also find out more about MIME by reading RFCs 2045 through to 2049, which you can access at http://www.rfc.net/.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.32.1