#! /bin/csh -fB
### This is a simple shell script for easy use of anonymous mail.  To run the
### program just save it and delete everything up until the #! /bin/csh -fB
### line.  Then just type the name you save it as or the name and whoever
### you will be mailing.  e.g.  amail bill@some.university.edu or just amail.
###

if ($1 != "") then
   set mto=$1
else
   echo 'To: '
   set mto=$<
endif

echo -n 'From: '
set mfrom=$<

echo -n 'Use which host for smtp (return for '`hostname`') ? '
set usehost=$<

echo -n 'Use which editor (return for vi)? '
set editor=$<
if($editor =="") then
   set editor=vi
endif

if ($mfrom == "") then
   set mfrom=`whoami`'@'`hostname`
endif

echo 'helo amail' >> tmpamail1
echo 'mail from: '$mfrom >> tmpamail1
echo 'rcpt to: '$mto >> tmpamail1
echo 'data' >> tmpamail1

$editor tmpamail2
clear
echo -n 'Are you sure you want to send this? '
set yorn=$<
if($yorn == 'y') then
   echo . >> tmpamail2
   echo quit >> tmpamail2
   cat tmpamail2 >> tmpamail1
   telnet $usehost  25 < tmpamail1 > /dev/null
   echo 'Mail has been sent to: '$mto
   echo '                 From: '$mfrom
endif
rm tmpamail1 tmpamail2

