Internet and Intranet Protocols and Applications


Programming Project 2.

Revision 1: Feb 12, 2002 (added link to RFC 821)

In this assignment you are asked to build a Message User Agent (MUA) that will send a mail message to an SMTP Mail server. As is the case with all of the programming assignments, you must write the program in JAVA. Here are the project requirements:

You must accept as input the following:

  1. Source email address
  2. Destination email address
  3. A message in plain text form (any simple one or two lines of text will do).

To send the message, you will need to implement a subset of the SMTP protocol. Specifically, you must implement the following commands:


Reply Code


















You will need to consult the class notes (from the lectures) and read RFC 821.

To simplify your task, you may treat ANY Reply Code other than the expected code in the above table as fatal error. That is, write a message like the one below and throw an IOException).

"Error: unexpected Reply Code. Sent command xxxx, received Reply yyyy"

where xxxx is the Command name and yyyy is the reply you received.

IMPORTANT: You will develop the user agent so that it sends mail to one recipient at a time. Furthermore, the user agent will assume that the domain name part of the recipient's email is the name of the SMTP server handling incoming mail for that recipient. The user agent WILL NOT perform a DNS lookup for an MX record, so the recipient's email address MUST be the actual name of the mail server.

For example, if you have a mail account on YAHOO, your program will fail if it tries to connect on port 25 to host (the mail server for is If you want to find out the name of a mail server for a given domain, then use one of the Web based DNS lookup utilities to find the MX record for the domain, like this one:

To further simplify your task, and to help those of you who are new to Java, we will provide you with four classes. Three of the classes are complete they have been written for you. The third class is a "skeleton", that is, you will have to fill in the code to make it work.

The classes are: A simple graphical application that accepts the program input, makes a message, and sends it. An object that represents the mailing envelope. An object that represents the message. A class the represents a connection to an SMTP Server and that implements the SMTP message user agent protocol. This is the class that you have to expand.

Since we expect you to send a trace of the interaction between your MUA and the SMTP server, You must log each send and each receive in the form:

SEND: xxxx

RECV: yyyy

Where xxxx is the EXACT content (text) of the command you send to the SMTP server, and yyyy is the EXACT response (the entire text line) you received from the server. If you fail to log EVERY interaction as requested we will deduct points from your score.

You can test your program by sending a message to your own mail account. When you are satisfied that you can send a message to ANY valid email destination address, then submit your program source ( ONLY) and the output from a successful test. We may use your SMTPConnection to send your grade to you, so make sure that it works!

How to submit:

Create a JAR file containing two text files:

  2. The protocol trace output as a text file.

To create the jar file, execute the command: jar cvf xxx.jar project1.log

Where project1.log is the name of the file you wrote output and xxx is YOUR STUDENT ID.

To be sure that we give credit to you, also include your name and student id as a comment at the beginning of the source file.

Note, you don't actually have to write the trace output to a file. You can write to System.out and redirect the standard output to a file. For example, you can run your program as:

Java MailClient > project1.log (note, you may need to specify a Classpath)

Send the jar file as an attachment in an email to the grader.

All emails MUST be dated prior to 5:00 PM on the due date.

You may send questions to the class mailing list ONLY.

The code for the four classes is HERE. They are in a jar file, so you will need to extract them.