SIMPLE MAIL TRANSFER
PROTOCOL (SMTP)
McGraw-Hill           ©The McGraw-Hill Companies, Inc., 2000
                   Introduction
   The actual mail transfer is done through message
    transfer agents (MTAs). To send mail, a system must
    have the client MTA, and to receive mail, a system
    must have a server MTA. The formal protocol that
    defines the MTA client and server in the Internet is
    called Simple Mail Transfer Protocol (SMTP).
   Two pairs of MTA client-server programs are used in
    the most common situation (fourth scenario).
   SMTP is used two times, between the sender and
    the sender’s mail server and between the two mail
    servers. Another protocol is needed between the
    mail server and the receiver.
   SMTP simply defines how commands and responses
    must be sent back and forth. Each network is free to
    choose a software package for implementation.
                                                           2
       SMTP uses commands and responses to transfer
        messages between an MTA client and an MTA
        server
       Each command or reply is terminated by a two-
        character (carriage return and line feed) end-of-
        line token.
       Commands are sent from the client to the server.
       SMTP commands consists of a keyword followed
        by zero or more arguments. SMTP defines 14
        commands listed in next table.
TCP/IP Protocol Suite                                       3
   Responses are sent from the server to the client.
    A response is a three-digit code that may be
    followed by additional textual information.
                                                        4
             Mail transfer phases
  The process of transferring a mail message occurs in
   three phases: connection establishment, mail
   transfer, and connection termination.
Connection Establishment
 After a client has made a TCP connection to the well-
   known port 25, the SMTP server starts the
   connection phase. This phase involves the following
   three steps, which are illustrated in next figure.
1. The server sends code 220 (service ready) to tell the
   client that it is ready to receive mail. If the server is
   not ready, it sends code 421 (service not available).
2. The client sends the HELO message to identify itself
   using its domain name address. This step is
   necessary to inform the server of the domain name
   of the client.
                                                               5
    3. The server responds with code 250 (request
       command completed) or some other code
       depending on the situation.
TCP/IP Protocol Suite                               6
    Message Transfer
     After connection establishment, a single message
       between a sender and one or more recipients can be
       exchanged. This phase involves eight steps.
     Steps 3 and 4 are repeated if there is more than one
       recipient
    1. The client sends the MAIL FROM message to
       introduce the sender of the message. It includes the
       mail address of the sender (mailbox and the domain
       name).
    2. The server responds with code 250 or some other
       appropriate code.
    3. The client sends the RCPT TO (recipient) message,
       which includes the mail address of the recipient.
    4. The server responds with code 250 or some other
       appropriate code.
TCP/IP Protocol Suite                                         7
    5. The client sends the DATA message to initialize
       the message transfer.
    6. The server responds with code 354 (start mail
       input) or some other appropriate message.
    7. The client sends the contents of the message in
       consecutive lines. Each line is terminated by a
       two-character end-of-line token (carriage return
       and line feed). The message is terminated by a
       line containing just one period.
    8. The server responds with code 250 (OK) or some
       other appropriate code.
    It is shown in next figure.
TCP/IP Protocol Suite                                     8
9
    Connection Termination
     After the message is transferred successfully, the
       client terminates the connection. This phase
       involves two steps.
    1. The client sends the QUIT command.
    2. The server responds with code 221 or some other
       appropriate code.
     After the connection termination phase, the TCP
       connection must be closed.
TCP/IP Protocol Suite                                      10
          POP3 & IMAP4
McGraw-Hill              ©The McGraw-Hill Companies, Inc., 2000
                         MAA
   The first and the second stages of mail delivery
    use SMTP. However, SMTP is not involved in the
    third stage because SMTP is a push protocol; it
    pushes the message from the client to the server
   The third stage needs a pull protocol; the client
    must pull messages from the server. The direction
    of the bulk data are from the server to the client.
    The third stage uses a message access agent.
   Currently two message access protocols are
    available: Post Office Protocol, version 3 (POP3)
    and Internet Mail Access Protocol, version 4
    (IMAP4).
   Figure next shows the position of these two
    protocols in the most common situation (fourth
    scenario).                                          12
TCP/IP Protocol Suite   13
                         POP3
   Post Office Protocol, version 3 (POP3) is simple and
    limited in functionality. The client POP3 software is
    installed on the recipient computer; the server
    POP3 software is installed on the mail server.
   Mail access starts with the client when the user
    needs to download its e-mail from the mailbox on
    the mail server. The client opens a connection to
    the server on TCP port 110. It then sends its user
    name and password to access the mailbox. The
    user can then list and retrieve the mail messages,
    one by one.
   Figure next shows an example of downloading
    using POP3.
                                                        14
TCP/IP Protocol Suite   15
       POP3 has two modes: the delete mode and the
        keep mode.
       In the delete mode, the mail is deleted from the
        mailbox after each retrieval. In the keep mode,
        the mail remains in the mailbox after retrieval.
       The delete mode is normally used when the user
        is working at his/her permanent computer and
        can save and organize the received mail after
        reading or replying. The keep mode is normally
        used when the user accesses his/her mail away
        from his/her primary computer.
       The mail is read but kept in the system for later
        retrieval and organizing.
TCP/IP Protocol Suite                                       16
                         IMAP
   Another mail access protocol is Internet Mail
    Access Protocol, version 4 (IMAP4).
   IMAP4 is similar to POP3, but it has more features;
    IMAP4 is more powerful and more complex.
   POP3 is deficient in several ways. It does not allow
    the user to organize his/her mail on the server; the
    user cannot have different folders on the server.
    (Of course, the user can create folders on his/her
    own computer.) In addition, POP3 does not allow
    the user to partially check the contents of the mail
    before downloading.
                                                       17
     IMAP4 provides the following extra functions:
    ❑ A user can check the e-mail header prior to
      downloading.
    ❑ A user can search the contents of the e-mail for a
      specific string of characters prior to downloading.
    ❑ A user can partially download e-mail. This is
      especially useful if bandwidth is limited and the e-
      mail contains multimedia with high bandwidth
      requirements.
    ❑ A user can create, delete, or rename mailboxes
      on the mail server.
    ❑ A user can create a hierarchy of mailboxes in a
      folder for e-mail storage.
TCP/IP Protocol Suite                                        18
                          MIME
   E-mail has a simple structure. But it can send
    messages only in NVT 7-bit ASCII format. It cannot be
    used for languages other than English. Also it can’t
    be used to send binary files or video or audio data.
   Multipurpose Internet Mail Extensions (MIME) is a
    supplementary protocol that allows non-ASCII data to
    be sent through e-mail.
   MIME transforms non-ASCII data at the sender site to
    NVT ASCII data & delivers it to the client MTA to be
    sent through the Internet. The message at the
    receiving site is transferred back to the original data.
   MIME is a set of software functions that transforms
    non-ASCII data & ASCII data & vice versa as show in
    the figure.
                                                           19
TCP/IP Protocol Suite   20
       MIME defines 5 headers that can be added to the
        original e-mail header section to define the
        transformation parameters:
        MIME version
        Content type
        Content transfer encoding
        Content ID
        Content description.
       Following figure shows the MIME headers
TCP/IP Protocol Suite                                     21
TCP/IP Protocol Suite   22
Dynamic Host Configuration Protocol
             (DHCP)
   Problems with BOOTP:
   A serious problem with BOOTP is that it
    requires   manual     configuration   of   tables
    mapping IP address to Ethernet address.
   When a new host is added to a LAN, it cannot use
    BOOTP until an administrator has assigned it an IP
    address and entered its (Ethernet address, IP
    address) into the BOOTP configuration tables by
    hand.
   To eliminate this error-prone step, BOOTP was
    extended and given a new name as DHCP (Dynamic
    Host Configuration Protocol).
                                                         23
        Dynamic Host Configuration
            Protocol (DHCP) …
   BOOTP extended and given a new name as
    Dynamic Host Configuration Protocol (DHCP) .
      DHCP allows both manual IP address
    assignment and automatic assignment. In most
    systems, it has largely replaced RARP and BOOTP.
   Like RARP and BOOTP, DHCP is based on the
    idea of a special server that assigns IP
    addresses to hosts asking for one. This server
    need not be on the same LAN as the requesting
    host. Since the DHCP server may not be reachable
    by broadcasting, a DHCP relay agent is needed
    on each LAN, as shown in Fig. 63.
                                                  24
    Dynamic Host Configuration
        Protocol (DHCP) …
Operation of DHCP:
                     Fig. 63
        Dynamic Host Configuration
            Protocol (DHCP) …
1.   To find its IP address, a newly-booted machine
     broadcasts a DHCP DISCOVER packet.
2.   The DHCP relay agent on its LAN intercepts all DHCP
     broadcasts. When it finds a DHCP DISCOVER
     packet, it sends the packet as a unicast packet
     to the DHCP server, possibly on a distant network.
     The only piece of information the relay agent needs is
     the IP address of the DHCP server.
3.   An issue that arises with automatic assignment of
     IP addresses from a pool is how long an IP
     address should be allocated.
                                                          26
        Dynamic Host Configuration
            Protocol (DHCP) …
•   If a host leaves the network and does not return its IP
    address to the DHCP server, that address will be
    permanently lost. After a period of time, many
    addresses may be lost.
•   To prevent that from happening, IP address
    assignment may be for a fixed period of time, a
    technique called leasing. Just before the lease
    expires, the host must ask the DHCP for a
    renewal. If it fails to make a request or the request is
    denied, the host may no longer use the IP address it
    was given earlier
                                                               27