Basics of How SMTP Works

Discussion in 'Web Development' started by lionaneesh, Feb 2, 2011.

  1. lionaneesh

    lionaneesh Active Member

    Joined:
    Mar 21, 2010
    Messages:
    848
    Likes Received:
    224
    Trophy Points:
    43
    Occupation:
    Student
    Location:
    India
    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

    [​IMG]

    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...
     
    Last edited by a moderator: Jan 21, 2017
  2. lionaneesh

    lionaneesh Active Member

    Joined:
    Mar 21, 2010
    Messages:
    848
    Likes Received:
    224
    Trophy Points:
    43
    Occupation:
    Student
    Location:
    India
    Thanks for accepting the article..and
    Thanks For the model...
     
  3. kumarmannu

    kumarmannu Banned

    Joined:
    Feb 2, 2011
    Messages:
    51
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  4. lionaneesh

    lionaneesh Active Member

    Joined:
    Mar 21, 2010
    Messages:
    848
    Likes Received:
    224
    Trophy Points:
    43
    Occupation:
    Student
    Location:
    India
    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_Mail_Transfer_Protocol
     
  5. shrikrishnatech

    shrikrishnatech New Member

    Joined:
    Nov 19, 2010
    Messages:
    42
    Likes Received:
    4
    Trophy Points:
    0
    Occupation:
    Wordpress theme, Wordpress Theming, WP Themes, Cor
    Home Page:
    http://www.shrikrishnatechnologies.com
    The following diagram has a simplified explanation of how the two protocols are used.
    [​IMG]
     
    Last edited: Feb 15, 2011
    shabbir likes this.
  6. ashwani6508

    ashwani6508 New Member

    Joined:
    Feb 22, 2011
    Messages:
    5
    Likes Received:
    1
    Trophy Points:
    0
    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:
     
    1 person likes this.
  7. alexsmth114

    alexsmth114 New Member

    Joined:
    Mar 7, 2011
    Messages:
    19
    Likes Received:
    1
    Trophy Points:
    0
    Really nice set of basics!!..
     
    1 person likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice