Email is one of the oldest network applications.
How email works is?
RFC 822 defines messages to have two parts: a header and a body. Both parts are represented in ASCII text. Originally, the body was assumed to be simple text. This is still the case, although RFC 822 has been augmented by MIME to allow the message body to carry all sorts of data. This data is still represented as ASCII text, but because it may be an encoded version of, say a JPEG image, it‟s not necessarily readable by human users.
More on MIME in a moment.
The message header is a series of <CRLF> terminated lines.(<CRLF> stands for carriage-return + line-feed, which are a pair of ASCII control characters often used to indicate the end of a line of text.) The header is separated from the message body by a blank line. Each header line contains a type and value separated by a colon. Many of these header lines are familiar to users since they are asked to fill them out when they compose an email message. For example ,the To:header identifies the message recipient , and theSubject:header says something about the purpose of the message. Other headers are filled in by the underlying mail delivery system.Examples include Date: (when the message was transmitted).From: (what user sent the message),and Received: (each mail server that handled this message).There are, of course ,many other header lines;the interested reader is referred to RFC 822.
These header lines describe, in various ways ,the data being carried in the message body. They include MIME-Version: (the version of MIME being used),
Content-Description: ( a human –readable description of what‟s in the message,analogous to theSubject:line),Content-Type:the type of data contained in the message),and Content-Transfer-Encoding(how the message body is encoded)
The second piece is definitions for a set of content types(and subtypes).For example ,MIME defines two different still-image types, denoted image/gif and image/jpeg,each with the obvious meaning. As another example ,text/plain refers to simple text you might find in a vanilla 822-style message ,while text/richtext denotes a message that contains “marked up” text (text using special fonts , italics, etc).As a third example, MIME defines an application type , where the subtypes correspond to the output of different application programs(eg.,application/postscript and application/msword).
MIME also defines a multipart type that says how a message carrying more than one data type is structured. This is like a programming language that defines both base types(eg.,integers and floats) and compound types (eg.,. structures and arrays).One possible multipart subtype is mixed ,which says that the message contains a set of independent data pieces in a specified order. Each piece then has its own header line that describes the type of that piece.
The third piece is a way to encode the various data types so they can be shipped in an ASCII email message. The problem is that for some data types(a JPEG image, for example),any given 8-bit byte in the image might contain one of 256 different values. Only a subset of these values are valid ASCII characters .It is important that email messages contain only ASCII ,because they might pass through a number of intermediate systems(gateways ,as described below) that assume all email is ASCII and would corrupt the message if it contained non-ASCII characters .To address this issue ,MIME uses a straightforward encoding of binary data into the ASCII character.The encoding is called base64.The idea is to map every three bytes of the original binary data into four ASCII characters .This is done by grouping the binary data into 24-bit units ,and breaking each such unit into four 6-bit pieces .Each 6-bit piece maps onto one of 64 valid ASCII character;for example ,0maps onto A,1 maps onto B ,and so on.If you look at a message that has been encoded using the base 64 encoding scheme,you will notice only the 52 uppercase and lowercase letters ,the 10 digits through 0 to9 ,and the special characters + and /.These are the first 64 values in the ASCII character set.