pipeto.sample (1765B)
1 #!/bin/rc 2 3 # create a /tmp for here documents 4 rfork en 5 bind -c /mail/tmp /tmp 6 7 KEY=whocares 8 USER=ken 9 10 RECIP=$1 11 MBOX=$2 12 PF=/mail/box/$USER/_pattern 13 TMP=/mail/tmp/mine.$pid 14 BIN=/bin/upas 15 D=/mail/fs/mbox/1 16 17 # save and parse the mail file 18 {sed '/^$/,$ s/^From / From /'; echo} > $TMP 19 upas/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 24 if( $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 } 31 switch($status){ 32 case *!match* 33 echo `{date} dropped $RECIP From `{cat $D/replyto} >> /mail/box/$USER/_bounced >[2] /dev/null 34 rm $TMP 35 exit 0 36 } 37 if ( $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 49 TOKEN=`{upas/token $KEY} 50 upasname=/dev/null 51 {{cat; cat $D/raw} | upas/send `{cat $D/replyto}}<<EOF 52 Subject: $USER's mail filter 53 I've been getting so much junk mail that I'm resorting to 54 a draconian mechanism to avoid the mail. In order 55 to make sure that there's a real person sending mail, I'm 56 asking you to explicitly enable access. To do that, send 57 mail to $USER at this domain with the token: 58 $TOKEN 59 in the subject of your mail message. After that, you 60 shouldn't get any bounces from me. Sorry if this is 61 an inconvenience. 62 63 ---------------- 64 Original message 65 ---------------- 66 EOF 67 68 echo `{date} bounced $RECIP From `{cat $D/replyto} \ 69 >> /mail/box/$USER/_bounced >[2] /dev/null 70 71 rv=$status 72 rm $TMP 73 exit $status