#! /bin/sh
#
# mail69
#
# Please read all comments (lines starting with "#") before using.
# This shell script will not work unless it is customized!
#
# Rename this file to "mail69" (`mv mail69.sh mail69`),
# make it executable (`chmod 755 mail69`),
# and put it in your PATH (`env` or `set` to check your PATH).

if [ $# -ne 0 ]; then
	echo "Usage: `echo $0 | sed 's|.*/||'`"
	echo "No command line parameters are accepted."
	exit 1
fi

# Set "Here" to your own alias, to avoid mailing your own packets
Here=tr

#cd dl	# or wherever you should be doing this

for packet in *69*.*; do
	if [ "*69*.*" = $packet ]; then echo "No packets found!"; exit 3; fi

#NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
# this is not yet implemented
# default encoding
	encode=uuencode
#NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE

# sed command strips off "69" and everything following, tr makes lowercase
	destination=`echo $packet | sed 's/69.*//g' | tr A-Z a-z`

# Not everyone here is ready to receive packets (yet)
# Be sure to end entries with _TWO_ semicolons
# $Here must be first, * must be last
	case $destination in

$Here)	echo "Skipping $packet (for here)"; continue;;
#bkm)	recipient=montyl@telcomplus.com;;
#btw)	recipient=dietra@mindless.com;;
#bwn)	recipient=n9348795@henson.cc.wwu.edu;;
#dy2)	recipient=iain@cc.wwu.edu;;
#ecl)	recipient=klaatu@clark.net;;
flr)	recipient=eric@sonic.net;;
gsg)	recipient=gldnspud@kali.nas.com;;
#hbc)	recipient=Tim@bailey.cpac.washington.edu;;
#hel)	recipient=shadowstalker@wsu.edu;;
#lab)	recipient=labrat@u.washington.edu;;
#oaf)	recipient=oafie@liii.com;;
#out)	recipient=stbob@clark.net;;
rai)	recipient=icewoolf@erols.com;;
#ras)	recipient=ranma@cosmos.ab.ca;;
skr)	recipient=amalmin@halcyon.com;;
sld)	recipient=litlnemo@seanet.com;;
teh)	recipient=mollyg@accessone.com; encode=mime;;
#tft)	recipient=sasha@halcyon.com;;
#tia)	recipient=canucks@u.washington.edu;;
tr)	recipient=goldfndr@eskimo.com;;
#ynh)	recipient=zakezuke@halcyon.com;;
*)	echo "Skipping $packet (I don't know how to send it)"; continue;;
	esac

# Choose one of these lines to send mail.  Fastmail is preferable.

#	case $encode in 
#uuencode)  uuencode $packet $packet | mail -s "Net 6.9 $encode packet: $packet" $recipient
	uuencode $packet $packet | fastmail -s "Net 6.9 packet: $packet" - $recipient
#mime)	mpack -s "Net 6.9 $encode packet: $packet" -c "application/x-zip-compressed" $packet $recipient
#	esac

	echo Sent $packet to $recipient
	rm $packet
done
