An e-mail sent from mail ID A to mail ID B goes through certain
manipulations and
 several layers of protocols and wrapping, unwrapping before it is delivered.

This article analyzes all that.

And guess what? Even this is sent on an e-mail.

Let us take the simplest example first. What is the bare minimum that
is required to
 do this job?

If we understand simple things we can get our head around complexity later.

Okay let us begin.

[email protected] sends a mail to [email protected]

This is the process:

A mail is typed on what is called as MUA or mail user agent.

MS Outlook, mutt, webmail(browser) or Evolution are all MUAs.

The way the mail is handed over to the Mail server or MTA(mail transfer agent)
 is using the SMTP protocol. But not the real SMTP which comes after that.

Normally in a network of say 3000 computers on a LAN, and even some VPN nodes
 remotely situated on the Internet, one mail server caters to all the 3000 MUAs
running on various client machines.

So an e-mail envelope just like a physical letter has two addresses,
from address
 and to address. In our case, the from is [email protected].
It is important
 since in the case of courier or registered post, it has to come back
to you if the
 to address is wrong.

The to address is [email protected] which has to now be broken up
into two parts.

User name ilugc and destination mail server domain which is ae.iitm.ac.in.

The MTA serving the 3000 nodes now has to talk SMTP to the process listening on
 ae.iitm.ac.in.

It does an MX record check like this:

$ dig +short ae.iitm.ac.in mx
10 www.ae.iitm.ac.in.
20 mailx1.iitm.ac.in.

$ dig +short www.ae.iitm.ac.in
203.199.213.51

$ nc -v 203.199.213.51 25
Connection to 203.199.213.51 25 port [tcp/smtp] succeeded!
220 aeserver.ae.iitm.ac.in ESMTP Postfix

As you can see above the mx is actually a host name and then find out
the IP address and
 finally we connect to the IP address and its 25 port.

Now the SMTP conversation starts like this:

EHLO gayatri-hitech.com
<pleased to meet you...>
MAIL FROM: <[email protected]>
<OK>
RCPT TO: <[email protected]>
<OK>
DATA
<331 End mail with a .>
Test mail
.
<OK Queued for delivery with id 0x3243243>
quit

That is it!

I have shown the mail server responses with a <>.

This is how an e-mail is sent.

Now the story does not complete here.

Once the mail reaches the server, it is stored in the mail box of the user
 ilugc.

The mail is ready by the destination user using his MUA just like the sender,
 when he downloads the mail using POP3 or IMAP.

He fetches the mail and the mail client or MUA unwraps the mail and
displays it in
 a window.

This is for simple text mail.

In case you are sending in HTML or attaching a video or mp3 or doc file, then
 also text is used to transmit mail.

But it is binary data encoded as text.

And there is an envelope format in which MIME encoding is used to separate out
 multiple MIME sections.

A boundary line will separate each section.

Each section corresponds to an attachment and the MUA displays it accordingly.

Mails are stored in the server after SMTP conversation using several methods,
 Maildir, MH, mbox and mboxrd.

Maildir is best.

Each mail is stored as a file in a directory MAILBOX/new. Every
maildir location
 has three directories:

new/
cur/
tmp/

This is to ensure that new mails being delivered do not overwrite existing ones.

In addition to all this there will be queuing, backup mx records, pipelining and
 several other advanced topics which I will cover in a later mail.

I will also show in the second part of this article a typical MIME
encoded message.

-Girish

-- 
Gayatri Hitech
http://gayatri-hitech.com
_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc

Reply via email to