[net.sources] A shell routine for interactive/friendly mail routine

msg@houxl.UUCP (M.GINGOLD) (09/28/84)

Well folks, it's simple but useful... This shell routine, dubbed "edmail"
prompts the sender of electronic mail for the subject:  
Then the shell produces the header complete with FROM and TO and DATE
info, puts the sender of mail into the EDITOR of their choice (based on the
variable EDITOR (from your .profile)... the default is "vi".

You can send mail to as many folk as you like... if you forget to put the
login of those people you wish to send mail to on the command line, edmail
will prompt you to supply the info...

Enjoy!

----------------------------  CUT HERE  ------------------------
# edmail routine		Marshall Gingold  9/26/84
#				AT&T Bell Laboratories, Holmdel, N.J.
# Synopsis: edmail [login login ...] or edmail <return>

if [ $1 ]
then
	name=$*
else
	echo "Whose login(s) do you want to send mail to? \c"
	read name
fi

# Create dummy file
file=/tmp/edmail$$

echo "SUBJECT	: \c" >> $file
echo "SUBJECT	: \c" 
read subject
echo $subject >> $file
echo "DATE	: `date`" >> $file
echo "FROM	: \c" >> $file

# Determine who is sending the mail

from=`grep $LOGNAME /etc/passwd|cut -d- -f2|cut -d\( -f1`
echo $from >> $file

echo "TO	: $name" >> $file
echo >> $file

# Assume that the user wants to use the same editor as set in their .profile
# Else, use vi as the default editor

NULL=""
if test "$EDITOR" = "$NULL"
then
	vi $file
else 
	$EDITOR $file
fi
/bin/mail $name < $file
rm $file