Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Web Development (http://www.go4expert.com/articles/web-development/)
-   -   Basics of How SMTP Works (http://www.go4expert.com/articles/basics-smtp-t24828/)

lionaneesh 2Feb2011 12:22

Basics of How SMTP Works
 
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

http://imgs.g4estatic.com/smtp/smtp-model.gif

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.net
From: lionaneesh@users.sourceforge.net
Cc:
Subject: Re : Regarding The Project
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Message-Id: <E1PkVWQ-0002qn-Cl@sfs-web-10.v29.ch3.sourceforge.com>
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...

lionaneesh 2Feb2011 13:43

Re: Basics of How SMTP Works
 
Thanks for accepting the article..and
Thanks For the model...

kumarmannu 2Feb2011 16:22

Re: Basics of How SMTP Works
 
Simple Mail Transfer Protocol (SMTP) is an Internet standard for electronic mail (e-mail) transmission across Internet Protocol (IP) networks. SMTP was first defined by RFC 821 (1982, eventually declared STD 10),and is the protocol in widespread use today. SMTP is specified for outgoing mail transport and uses TCP. The protocol for new submissions is effectively the same as SMTP, but it uses port 587 instead.

While electronic mail servers and other mail transfer agents use SMTP to send and receive mail messages, user-level client mail applications typically only use SMTP for sending messages to a mail server for relaying. For receiving messages, client applications usually use either the Post Office Protocol (POP) or the Internet Message Access Protocol (IMAP) or a proprietary system (such as Microsoft Exchange or Lotus Notes/Domino) to access their mail box accounts on a mail server.

An SMTP transaction consists of three command/reply sequences (see example below.) They are:

1. MAIL command, to establish the return address, a.k.a. Return-Path, 5321.From, mfrom, or envelope sender. This is the address for bounce messages.
2. RCPT command, to establish a recipient of this message. This command can be issued multiple times, one for each recipient. These addresses are also part of the envelope.
3. DATA to send the message text. This is the content of the message, as opposed to its envelope. It consists of a message header and a message body separated by an empty line. DATA is actually a group of commands, and the server replies twice: once to the DATA command proper, to acknowledge that it is ready to receive the text, and the second time after the end-of-data sequence, to either accept or reject the entire message.

lionaneesh 2Feb2011 20:56

Re: Basics of How SMTP Works
 
Quote:

Originally Posted by kumarmannu (Post 78697)
Simple Mail Transfer Protocol (SMTP) is an Internet standard for electronic mail (e-mail) transmission across Internet Protocol (IP) networks. SMTP was first defined by RFC 821 (1982, eventually declared STD 10),and is the protocol in widespread use today. SMTP is specified for outgoing mail transport and uses TCP. The protocol for new submissions is effectively the same as SMTP, but it uses port 587 instead.

While electronic mail servers and other mail transfer agents use SMTP to send and receive mail messages, user-level client mail applications typically only use SMTP for sending messages to a mail server for relaying. For receiving messages, client applications usually use either the Post Office Protocol (POP) or the Internet Message Access Protocol (IMAP) or a proprietary system (such as Microsoft Exchange or Lotus Notes/Domino) to access their mail box accounts on a mail server.

An SMTP transaction consists of three command/reply sequences (see example below.) They are:

1. MAIL command, to establish the return address, a.k.a. Return-Path, 5321.From, mfrom, or envelope sender. This is the address for bounce messages.
2. RCPT command, to establish a recipient of this message. This command can be issued multiple times, one for each recipient. These addresses are also part of the envelope.
3. DATA to send the message text. This is the content of the message, as opposed to its envelope. It consists of a message header and a message body separated by an empty line. DATA is actually a group of commands, and the server replies twice: once to the DATA command proper, to acknowledge that it is ready to receive the text, and the second time after the end-of-data sequence, to either accept or reject the entire message.

If you are copy-pasting data from source you should add a line at the end of the document you are taking..
Like this one is entirely taken from wikipedia

So add :-

Source : http://en.wikipedia.org/wiki/Simple_...nsfer_Protocol

shrikrishnatech 15Feb2011 12:33

Re: Basics of How SMTP Works
 
The following diagram has a simplified explanation of how the two protocols are used.
http://www.applix.net/pop%20and%20smtp_small1.jpg

ashwani6508 22Feb2011 18:17

Re: Basics of How SMTP Works
 
The SMTP Server
email

Whenever you send a piece of e-mail, your e-mail client interacts with the SMTP server to handle the sending. The SMTP server on your host may have conversations with other SMTP servers to deliver the e-mail.

Let's assume that I want to send a piece of e-mail. My e-mail ID is brain, and I have my account on howstuffworks.com. I want to send e-mail to jsmith@mindspring.com. I am using a stand-alone e-mail client like Outlook Express.

When I set up my account at howstuffworks, I told Outlook Express the name of the mail server -- mail.howstuffworks.com. When I compose a message and press the Send button, here's what happens:

1. Outlook Express connects to the SMTP server at mail.howstuffworks.com using port 25.
2. Outlook Express has a conversation with the SMTP server, telling the SMTP server the address of the sender and the address of the recipient, as well as the body of the message.
3. The SMTP server takes the "to" address (jsmith@mindspring.com) and breaks it into two parts: the recipient name (jsmith) and the domain name (mindspring.com). If the "to" address had been another user at howstuffworks.com, the SMTP server would simply hand the message to the POP3 server for howstuffworks.com (using a little program called the delivery agent). Since the recipient is at another domain, SMTP needs to communicate with that domain.
4. The SMTP server has a conversation with a Domain Name Server, or DNS (see How Web Servers Work for details). It says, "Can you give me the IP address of the SMTP server for mindspring.com?" The DNS replies with the one or more IP addresses for the SMTP server(s) that Mindspring operates.
5. The SMTP server at howstuffworks.com connects with the SMTP server at Mindspring using port 25. It has the same simple text conversation that my e-mail client had with the SMTP server for HowStuffWorks, and gives the message to the Mindspring server. The Mindspring server recognizes that the domain name for jsmith is at Mindspring, so it hands the message to Mindspring's POP3 server, which puts the message in jsmith's mailbox.

If, for some reason, the SMTP server at HowStuffWorks cannot connect with the SMTP server at Mindspring, then the message goes into a queue. The SMTP server on most machines uses a program called sendmail to do the actual sending, so this queue is called the sendmail queue. Sendmail will periodically try to resend the messages in its queue. For example, it might retry every 15 minutes. After four hours, it will usually send you a piece of mail that tells you there is some sort of problem. After five days, most sendmail configurations give up and return the mail to you undelivered.

The SMTP server understands very simple text commands like HELO, MAIL, RCPT and DATA. The most common commands are:

alexsmth114 21Mar2011 11:24

Re: Basics of How SMTP Works
 
Really nice set of basics!!..


All times are GMT +5.5. The time now is 11:12.