Comparison with HTTP / MaiI Message Formats

Comparison with HTTP / MaiI Message Formats

Comparison with HTTP

Let's now compare SMTP with HTTP in brief. Both protocols are used to transfer files from one host to another: HTTP transfers files (also called objects) from a Web server to a Web client (typically a browser); SMTP transfers files (that is, e-mail messages) from one mail server to another mail server. When transferring the files, both persistent HTTP and SMTP use persistent connections. Therefore, the two protocols have common characteristics. On the other hand, there are important differences. First, HTTP is basically a pull protocol - someone loads information on a Web server and users use HTTP to pull the information from the server at their convenience. Particularly, the TCP connection is started by the machine that wants to receive the file. On the other hand, SMTP is mainly a push protocol - the sending mail server pushes the file to the receiving mail server. Particularly, the TCP connection is initiated by the machine that wants to send the file.

A second difference, which we mentioned earlier, is that SMTP requires each message, including the body of each message, to be in 7-bit ASCII format. If the message includes characters that are not 7-bit ASCII (for instance, French characters with accents) or includes binary data (such as an image file), then the message has to be encoded into 7-bit ASCII. HTTP data does not impose this restriction.

A third important difference concerns how a document consisting of text and images (along with possibly other media types) is handled. As we learned in "The Web and HTTP", HTTP encapsulates each object in its own HTTP response message. Internet mail places all of the message's objects into one message.

MaiI Message Formats

When Alice writes an ordinary snail-mail letter to Bob, she may contain all kinds of peripheral header information at the top of the letter, such as Bob's address, her own return address, and the date. Likewise, when an e-mail message is sent from one person to another, a header including peripheral information precedes the body of the message itself. This peripheral information is included in a series of header lines, which are defined in RFC 5322. The header lines and the body of the message are separated by a blank line (that is, by CRLF). RFC 5322 specifies the exact format for mail header lines as well as their semantic interpretations. As with HTTP, each header line includes readable text, comprising a keyword followed by a colon followed by a value. Some of the keywords are needed and others are optional. Every header must have a From: header line and a To: header line; a header may contain a Subject: header line as well as other optional header lines. It is important to note that these header lines are different from the SMTP commands we studied in "SMTP" (even though they include some common words such as "from" and "to"). The commands in that section were part of the SMTP handshaking protocol; the header lines studied in this section are part of the mail message itself.

A usual message header looks like this:

Subject: Searching for the meaning of life.

After the message header, a blank line follows; then the message body (in ASCII) follows. You should use Telnet to send a message to a mail server that includes some header lines, including the Subject: header line. To do this, issue telnet serverName 25, as discussed in "SMTP".


pull protocol, push protocol, peripheral information, http, smtp, mail server

Copy Right

The contents available on this website are copyrighted by TechPlus unless otherwise indicated. All rights are reserved by TechPlus, and content may not be reproduced, published, or transferred in any form or by any means, except with the prior written permission of TechPlus.