In this
exercise you will implement a mail user agent (mail client) that sends mail to
remote hosts. Your task is to program the SMTP interaction between the Mail
User Agent (MUA) and the remote SMTP server.
java MailClient
<sender> <”comma-separated-recipents-list”>
<”body”> <”subject”> <port>
Example: java MailClient com1@cs.huji.ac.il
”daniel51@cs.huji.ac.il,adaliot@cs.huji.ac.il”
”Hello…” ”This is Ex1.” 25
You should implement only the
commands HELO, MAIL FROM, RCPT TO, DATA, QUIT.
The implementation should be
done in Java using TCP.
The program should return 0 when
successful, and System.exit(1) on error.
You should implement the char
stuffing algorithm we talked about in class. (See SMTP RFC section 4.5.2 http://www.faqs.org/rfcs/rfc821.html)
S: 220 hamburger.edu
C: HELO crepes.fr
S: 250 Hello crepes.fr, pleased to meet you
C: MAIL FROM: <alice@crepes.fr>
S: 250 alice@crepes.fr... Sender ok
C: RCPT TO: <bob@hamburger.edu>
S: 250 bob@hamburger.edu ... Recipient ok
C: DATA
S: 354 Enter mail, end with "."
on a line by itself
C: Date: 23 Oct 81 11:22:33
C: From: SMTP@HOSTY.ARPA
C: To: JOE@HOSTW.ARPA
C: Subject: Mail System Problem
C:
C: Sorry JOE, your message to SAM@HOSTZ.ARPA lost.
C: HOSTZ.ARPA said this:
C: "550 No Such User"
C: .
S:
250 Message accepted for delivery
C: QUIT
S: 221 hamburger.edu closing connection
You
should check the server error codes. In case of error, the program should System.exit(1)
Command |
Reply Code |
DATA |
354 |
HELO |
250 |
MAIL FROM |
250 |
QUIT |
221 |
RCPT TO |
250 |
The above table also lists the accepted reply codes for each of the SMTP commands you need to implement. For simplicity, you can assume that any other reply from the server indicates a fatal error and abort the sending of the message. In reality, SMTP distinguishes between transient (reply codes 4xx) and permanent (reply codes 5xx) errors, and the sender is allowed to repeat commands that yielded in a transient error. See Appendix E of RFC 821 for more details.
In addition, when you open a connection to the server, it will reply with the code 220.
Open
a connection from inside HUJI CS network to mail.cs.huji.ac.il
and send a message to yourself.
You
should implement one file called MailClient.java . In a README file write on the first line the logins of
the two students which submitted this exercise separate by comma. Next write
the full names.
Submit
a tar file using the course-admin submission system:
tar cvzf ex1.tgz MailClient.java README
com1@beach:~/www/Exercises/Ex1# ~com1/www/checkme_ex1.sh ex1.tgz
Running on host: beach
Please verify that you check the program on either mangal or inferno
Going to open tar file: ex1.tgz
README
MailClient.java
Found exercise submitted by logins: moshe,ofnik
Please verify that logins are correct and seperated by comma
Trying to compile exercise
Compilation OK
Tar file OK!
com1@beach:~/www/Exercises/Ex1#
The exercises will be checked
using uniform random sampling. Any mistake in creating the tar or README files, will result in 10 points penalty.
http://www.faqs.org/rfcs/rfc821.html