As we have already seen , how domain name system (DNS) really works for our numerous queries in search engines in everyday life. So now its time for us to understand the most interesting feature of the ‘Application Layer‘ i.e the working of electronic mail(e-mail) over the internet.
We all are a social animal, and we can’t survive without communicating anyone in this world for our needs.
And indeed an email service is a part and parcel of our daily life. Have you ever wonder how this wonderful feature really works and help us communicating with someone else(in any part of the world). So let us understand this now.
Email Services and Architecture
An email application consists of two subsystems:
- User agents (UA): It provides service to the user to make the process of sending and receiving a message easier. This enables users to read and send emails.
- Message transfer agents (MTA): This helps in moving the message from sender to receiver .(this we will see in detail in the next post)
Basic functions of an email application:
In this , mainly a user agent template is provided to the user for composing a message. The basic process of composing/drafting a message and to reply to them is present in this. A user agent helps the user to compose the e-mail message that is to be sent out. Most user agents provide a template on the screen to be filled in by the respective user.
2. Transfer : The process of transferring a composed message from the sender to the recipient. Connection establishment between the sender and receiver forms an integral part of this process.
3. Displaying : The process of displaying the incoming message to the receiver will be done in this section.
4. Disposition : This mainly deals with the action performed by the receiver user.This is the final step in the email process.Some of the options present for the user are :
- Forwarding or replying
- Save message
- Throw after reading
- Throw before reading
After reading a message, a user can use the user agent in order to reply to a message. A user agent generally allows the user to reply to the original sender.
A user agent basically creates two mailboxes, an inbox, and an outbox. Each box consists of a file with a special format that can be handled by the user agent.
The inbox further keeps all the received e-mails until they are all deleted by the user. Further, the outbox will contain all the sent mails until they are deleted.
Email Envelop and message
There is a distinction present between the email and its contents.An email envelope contains the message , receiver address ,sender address, security etc . The message transfer agents such as Simple mail transfer protocol (SMTP) use this envelope for routing.
The message contains the header and the body. The header of the message defines the sender, the receiver, the subject of the message.Header contains the control information and the body contains the message contents.
Email address format
Any address mainly consists of two parts i.e. local path and the domain name(both separated by ‘@’ symbol).To deliver mail, a mail handling system must use an addressing system with unique addresses.
The local part defines the name of a special file, called the user mailbox and the second part of the address is the domain name. For eg in firstname.lastname@example.org , ‘electronicscrunch’ is the local name and ‘gmail.com’ is referring to the domain name.
Email Message Formats (RFC 822):
We will now see the message format of an email message. Initially the user agent will build the message and then it passes the message to the message transfer agent for its required routing. Any message mainly comprises of header fields(ASCII character set) , message body , envelop, and a blank line.
|To||Email (DNS address)of the primary recipients|
|Cc||Email address of the secondary recipients(Carbon copy)|
|Bcc||Email address of the blind carbon copies|
|From||Originator of the message|
|Sender||Email address of the sender|
|Received||Line added by each transfer agent along the route|
|Return path||Used to identify the path back to the sender|
MIME – Multipurpose Internet Mail Extensions :
First things first , let’s understand the limitations of the old email system. In early days only text messages were present in the emails, in more technical terms the old email system can send messages only in NVT 7-bit ASCII format. This basically means :
It cannot be used for languages that are not supported by the 7-bit ASCII characters (such as French, German, Hebrew, Russian, Chinese, and Japanese).
Also, it cannot be used to send binary files or video or audio data. Thus it cannot be used for languages that do not contain alphabets(eg Chinese and Japanese) and which contain some non-Latin alphabets such as Russian and Hebrew .
To overcome these limitations , the solution proposed is a new mail system i.e the RFC 1341(then updated to RFC 1521) . The solution is the implementation of MIME (Multipurpose Internet Mail Extension) for the email services.
Principle of MIME (Multipurpose Internet Mail Extension)
MIME uses the same RFC 822 format but it adds structure to the message body(In RFC 822 there is no structure to the message body.)
MIME transforms non-ASCII data at the sender site to NVT ASCII data and delivers them to the client MTA (message transfer agent) to be sent through the Internet. The message at the receiving side is then transformed back to the original data.
In addition to this , MIME defines encoding rules for non-ASCII messages. It is possible to send MIME messages using the existing mail program and protocols. The sending and receiving programs need to be changed to achieve this, which users can do themselves.
New message headers:
Five new messages headers are defined for MIME . They are listed in table.
|Sr No||Header Name||Description|
|1||MIME – Version||Shows MIME version|
|2||Content – Description||Shows what is in the message|
|3||Content – Id||Identifier|
|4||Content – Transfer – Encoding||Indicated how the body is wrapped
|5||Content – Type||Type of message|
It tells the users agent that this message is a MIME message and it also specifies the versions of MIME being used.
This header tells what the message is all about. It is in the form of ASCII string . This header is needed because the recipient will know whether it is worth decoding and reading the message .
This field identifies the contents. Its format is the same as the format of standard Message –Id header .
This field tells how the body is wrapped for transforming through a network .The network can object to most characters except for the letter ,numbers, and punctuation marks.
Five schemes are provided for this purpose in addition to an escape to new schemes.These schemes are as follows:
The first scheme simply uses ASCII text. Each ASCII character uses 7-bits and can be carried directly if each line contains at the most 1000 characters.
The second scheme is similar to the first scheme except for one changed. Instead of 7-bit characters,now 8-bit characters are used. The maximum line length remains unchanged.
The third is the message using binary encoding. The problems with these messages are that they do not always use all the 8-bits and do not stick to the 1000 line per character limit. There is no guarantee that these messages arrive error free.
The fourth type is encoded binary message using base 64-encoding which is also called as ASCII armor.
The fifth type is the messages with a special type of encoding called quoted-printable encoding.
- Content –type:
This is the last header in the table and it is used to specify the type of the message body. RFC 1521 defines seven types with each one having one or more subtypes.
The type and subtype are separated by a slash such as ,
The subtype must be given in the header .The MIME types and subtypes in RFC 1521 :
|Text||Plain||Text in the unformatted way.|
|Richtext||The text includes simple formatting
|Image||Gif||Still pictures in GIF format|
|Jpeg||Still pictures in JPEG format|
|Audio||Basic||Audio or sound content|
|Video||Mpeg||Video in MPEG format.|
|Application||Octet-stream||Byte sequence in uninterpreted form.|
|Post script||A printable document in Post Script|
|Message||RFC 822||A MIME RFC 822 message|
|Partial||Body is a fragment of a bigger message|
|External Body||Body is a reference to another message|
|Multipart||Mixed||Body contains ordered parts of different data types|
|Alternative||Same message in different formats|
|Parellel||Parts must be viewed simultaneously (no order)|
|Digest||Each part is a complete RFC 822 message.|
- Note that many new types have been added to the basic list of tables and the addition is still being made. Let us discuss the content type listed in the table.
The Text type is for straight text . There are two subtypes namely plain and richtext.
The text /plain combination represents the original messages without any encoding or further processing.
The Text/richtext allows simple formatting in the text. It allows the text with boldface , italics,small and large point sizes,indentations, subscripts,page layout etc.
2. Image :
- This MIME type is used for transmitting still pictures. There are many formats used for storing and transmitting image with or without compression.
- The two subtypes are GIF and JPEG.
3. Audio and Video
Audio is for sound and video is for moving picture. It supports only one video standard i.e MPEG designed by “Moving Picture Experts Group”.
It is used for formats that require external processing . It mainly consists of two subtypes i.e. the octet stream , which is a sequence of bytes . The other type is postscript. It corresponds to the language produced by Adobe system.
This allows one message to be fully encapsulated inside other message .(used in order to forward emails).
This allows a message to contain multiple parts in the same message. There are four subtypes. The mixed subtype allows each part to be different. In an alternative subtype, each part should contain the same message expressed with a different encoding. The parallel subtype is used to view simultaneous parts at a time.
The last subtype i.e. digest is used when many messages are packed together to form a composite message.
In the next post, we will see how a message transfer agent works in real life (SMTP protocol) in detail. Hope to see you in my next post. Stay tuned..
Aric is a tech enthusiast , who love to write about the tech related products and ‘How To’ blogs . IT Engineer by profession , right now working in the Automation field in a Software product company . The other hobbies includes singing , trekking and writing blogs .