1#!/bin/rc 2 3# create a /tmp for here documents 4rfork en 5bind -c /mail/tmp /tmp 6 7KEY=whocares 8USER=ken 9 10RECIP=$1 11MBOX=$2 12PF=/mail/box/$USER/_pattern 13TMP=/mail/tmp/mine.$pid 14BIN=/bin/upas 15D=/mail/fs/mbox/1 16 17# save and parse the mail file 18{sed '/^$/,$ s/^From / From /'; echo} > $TMP 19upas/fs -f $TMP 20 21# if we like the source 22# or if the subject contains a valid token 23# then deliver the mail and allow all the addresses 24if( $BIN/list check $PF $D/from $D/sender $D/replyto ) 25{ 26 $BIN/deliver $RECIP $D/from $MBOX < $D/raw 27 $BIN/list add $PF $D/from $D/to $D/cc $D/sender 28 rm $TMP 29 exit 0 30} 31switch($status){ 32case *!match* 33 echo `{date} dropped $RECIP From `{cat $D/replyto} >> /mail/box/$USER/_bounced >[2] /dev/null 34 rm $TMP 35 exit 0 36} 37if ( $BIN/token $KEY $D/subject ) 38{ 39 $BIN/deliver $RECIP $D/from $MBOX < $D/raw 40 $BIN/list add $PF $D/from $D/to $D/cc $D/sender 41 rm $TMP 42 echo `{date} added $RECIP From `{cat $D/replyto} \ 43 >> /mail/box/$USER/_bounced >[2] /dev/null 44 exit 0 45} 46 47# don't recognize the sender so 48# return the message with instructions 49TOKEN=`{upas/token $KEY} 50upasname=/dev/null 51{{cat; cat $D/raw} | upas/send `{cat $D/replyto}}<<EOF 52Subject: $USER's mail filter 53I've been getting so much junk mail that I'm resorting to 54a draconian mechanism to avoid the mail. In order 55to make sure that there's a real person sending mail, I'm 56asking you to explicitly enable access. To do that, send 57mail to $USER at this domain with the token: 58 $TOKEN 59in the subject of your mail message. After that, you 60shouldn't get any bounces from me. Sorry if this is 61an inconvenience. 62 63---------------- 64Original message 65---------------- 66EOF 67 68echo `{date} bounced $RECIP From `{cat $D/replyto} \ 69 >> /mail/box/$USER/_bounced >[2] /dev/null 70 71rv=$status 72rm $TMP 73exit $status 74