Assignment #1

Deadline: January 25, 2005

Submission

The directory tree for this submission should be (relative to your WebDAV root):
/
/a1
/a1/sm.sh

Description

The basis for this assignment are the basic scripts and the prototypical mailer. You will also need to consult RFC 821 for details of the protocol. Write a Bash script named sm.sh ("Send mail") which accept the following format:
[your shell prompt]% sm.sh -S smtpserver -P port -M file addr1 addr2 addr3 
where smtpserver is the name or IP address of the SMTP server that the user of the script has access to, and -P is the port of the server. The port should default to 25 if not specified. The words addr1, addr2, etc.are expected to be e-mail addresses but they do not have to be valid. The option -M specifies the name of the file from which to take the message. If not specified, the message should be read from the standard input. The script should output the following
addr1 status1 message1
addr2 status2 message2
...
where statusN is the status number returned from the SMTP server, and messageN is a string identifying the problem, if any. For simplicity, you need to interpret only the top level of detail of the 3-digit status returned by the SMTP server. You are not required, but encouraged to consider the following situations: The script should return 0 if the server exists and answers positively to your initial query, and return 1 if the server will fail to connect. You may use a timeout of a few seconds to handle non-responsive SMTP servers, in which you also return 1.
Marek Rychlik <rychlik@u.arizona.edu>
Last modified: Wed Jan 19 13:54:02 MST 2005