Simple Mail Transfer Protocol

  • transport layer service used: TCP
  • port number: 25

    Alice is sending letter to Bob what happens to the letter:

    1. Alice mail user-agent forms an SMTP message and send it to Alice's mail server.
    2. Alice's mail server realizes that the destination address does not belong to this server and sends a corresponding message to Bob's mail server
    3. Bob invokes his mail user agent to get his letters from the server.
    Warning: Step 3 can not be done using SMTP!

    The SMTP commands define the mail transfer or the mail system function requested by the user. SMTP commands are character strings terminated by CR+LF. The commands themselves are alphabetic characters terminated by space if parameters follow and CR+LF otherwise.

    Sending letter scenario

    HELO marshall.edu
    MAIL FROM: <dementiev@marshall.edu>
    RCPT TO: <danil@mathcs.emory.edu>
    RCPT TO: <dementiev@marshall.edu>
    DATA
    This is my test e-mail from SMTP server.
    Dan.
    .
    QUIT
    
    Official information about Simple Mail Transfer Protocol can be found in RFC2821.

    Comparison with HTTP.

    1. push vs. pull
    2. 7-bit content vs. 8-bit content
    3. multipart messages (images & attachments). One message vs. sequence of messages.

    Q: How to send different kind of information in one message?
    A: MIME (Multipurpose Internet Mail Extension)

    Header of the mail

    Format is described in standard of the internet text messages.
    HELO mathcs.emory.edu
    MAIL FROM: <danil@mathcs.emory.edu>
    RCPT TO: <dementiev@marshall.edu>
    RCPT TO: <_dementiev@marshall.edu>
    DATA
    From: someaddr@somewhere.edu
    To: dementiev@marshall.edu
    Subject: IST362 MIME encoding
    MIME-Version: 1.0
    
    Hello,
    this is a test message for IST362 class sent via direct TCP connection to Marshall SMTP server.
    Sincerely,
    Daniel
    .
    QUIT
    

    The MIME extension for non-ASCII data

    MIME (Multipurpose Internet Mail Extension) is a special extension to RFC 822 - Standard for the format of ARPA Internet text messages. MIME is defined in RFC 2045 and RFC 2046. Base 64 is one of the standards to convert 8-bit data into 7-bit data. Windows version of the program that does it is here. And this is a scenario that send a picture:
    HELO mathcs.emory.edu
    MAIL FROM: <danil@mathcs.emory.edu>
    RCPT TO: <dementiev@marshall.edu>
    RCPT TO: <_dementiev@marshall.edu>
    DATA
    From: someaddr@somewhere.edu
    To: dementiev@marshall.edu
    Subject: IST362 MIME encoding
    MIME-Version: 1.0
    Content-Transfer-Encoding: base64
    Content-Type: image/gif
    
    R0lGODlhDwAPAKL/AP+9AP/GAP/OAP/eCP/vEMDAwAAAAAAAACH5BAEAAAUALAAAAAAPAA8A
    QANGWKrWvSyIKYa9g5higDPCN2wMZhEoyQBs4FLkJ8/cNIopxHz60rSuh48FcEkoIw7rE3JY
    GkGn6AYzGTIajumCyvquWI0qAQA7
    .
    QUIT
    
    Using MIME we can text and binary data in on letter:
    HELO mathcs.emory.edu
    MAIL FROM: <danil@mathcs.emory.edu>
    RCPT TO: <dementiev@marshall.edu>
    RCPT TO: <_dementiev@marshall.edu>
    DATA
    From: someaddr@somewhere.edu
    To: dementiev@marshall.edu
    Subject: IST362 MIME encoding
    MIME-Version: 1.0
    Content-Type: multipart/mixed; boundary=gc0p4Jq0M2Yt08j34c0p
    
    --gc0p4Jq0M2Yt08j34c0p
    Content-Type: text/plain
    
    Hello,
    this is a test message for IST362 class sent via direct TCP connection to Marshall SMTP server.
    This message also includes this image:
    --gc0p4Jq0M2Yt08j34c0p
    Content-Transfer-Encoding: base64
    Content-Type: image/gif
    
    R0lGODlhDwAPAKL/AP+9AP/GAP/OAP/eCP/vEMDAwAAAAAAAACH5BAEAAAUALAAAAAAPAA8A
    QANGWKrWvSyIKYa9g5higDPCN2wMZhEoyQBs4FLkJ8/cNIopxHz60rSuh48FcEkoIw7rE3JY
    GkGn6AYzGTIajumCyvquWI0qAQA7
    --gc0p4Jq0M2Yt08j34c0p
    
    Sincerely,
    Daniel
    --gc0p4Jq0M2Yt08j34c0p--
    .
    QUIT
    

    Links