#!/bin/sh

# dws [ box ] [ id ]
#
# die worthless spammer

myname="`basename \"$0\"`"
spam=+spam

case "`box`" in
$spam)
	echo "$myname: Replying to a spam in \"$spam\"?" 1>&2
	exit 1
	;;
esac

case $# in
0|1|2)
	mov ${1+"$@"} "$spam" || exit $?
	;;

*)
	echo "usage: $myname [ box ] [ id ]" 1>&2
	exit 1
	;;
esac

box="`box`"

box "$spam" || exit $?

# construct reply
(
	EDITOR='sam -d' rep -i > /dev/null 2>&1 <<'!'
/^To:.*\n(    .*\n)+/
x/\n    /c/ /
/^To:.*\n/
.t.
x/[\-a-zA-Z0-9._&]+@/c/postmaster@/
/^To:.*\n/
/^To:.*\n/
s/^To:/Cc:/
,x/^Cc: \n/d
,x/^Bcc: \n/d
,x/^Subject: \n/d
1,/^\n/
a
die, worthless spammer.

postmaster: check out the Mail Abuse Protection System (MAPS)
	    http://maps.vix.com

.
1,/^$/p
w
q
!
# log reply and deliver
) || exit 1

case "$myname" in
dws)
	echo "$myname: Spam returned to `msg | 822flatten | sed -e '/^[TC][oc][ 	]*:[ 	]*/!d' -e 's///' | tr '\012' ' '`" 1>&2
	del && box "$box"
	;;

rws)
	med
	;;
esac


© 1998, Boyd Roberts: boyd@fr.inter.net