SMTP stands for Simple Mail Transfer Protocol as the name suggest it is basically used for emails.. SMTP specified for outgoing mail uses and default sits on TCP Port 25..(Uses 587 in new versions) Electronic mail servers uses SMTP for send and receive emails while the User Client interface only uses SMTP mainly for sending messages to the mail servers..for relaying...

For receving emails the User Client applications mainly use POP (Post office Protocol) and IMAP (Internet Messaging Access Protocol)..

Structure of a Email

Code:

SomeNameLikelionaneesh@gmail.com     |			|     |			|  Username	Hostname (The domain name on which the user is registered...)

The Flow Of Message



Firstly as the user writes and the mail is submitted (by MUA Mail User Agent) to a Mail Server (MSA, Mail Submission Agent ) using SMTP on TCP Port 25 or 587..From there the Mail Submission Agent submits the mail to the Mail Transfer Agent(Mail transfer Agent) ..Each Process is a a Mail Transfer Agent in its own right , I.e an SMTP server...

Then the Boundary Mail transfer Agent locates the target host by looking up the host-name in DNS to look up the mail exchange record for the target's (recipient's) Domain name.. 

Then the MTA (Mail transfer Agent ) further looks for the A record in order to get the ip address of the target..

Then it connects to the host's ip as an SMTP Client..

Once the host accepts the requests it hands on the email to the MDA (Mail Delivery Agent)..
The mail delivery agent is used for the local mail delivery..

Once Delivered to the local mail server , the mail is stored for batch retrieval by authentication mail clients (MUA's)..

Then The Mail is received by the End-User's mail client , using IMAP or POP...

IMAP - It is a Protocol that allows both access to the mail and managing stored emails..

POP - It is a Protocol is used to retrieve emails...

Model



Commands 



SMTP is similar to any other INTERNET protocol like HTTP , FTP etc...Just like them SMTP session includes issuing of some commands between server and client..

The SMTP session basically includes 3 command/reply pairs..

  1. MAIL - This command is basically used to establish return address or Return path...This is basically a address for bounce messages

  2. RCPT - This command is to establish the recipient of a message … The command is issued multiple times for multiple recipients

  3. DATA - This is the main command that to send the message text..It consists of a message header and a message body..

Example of message header :-

Code:

To: lionaneesh@users.sourceforge.netFrom: lionaneesh@users.sourceforge.netCc: Subject: Re : Regarding The ProjectMime-Version: 1.0Content-Type: text/plain; charset="UTF-8"Message-Id: 
Date: Wed, 02 Feb 2011 05:44:54 +0000

Example of Message Body :-

Code:

Hello World.... Howz you...I am a message body...

That's all for this article and stay tuned for more...