#!/bin/sh # forrep 1.0 by Doug Muth (dmuth@ot.com) # This program may be freely distributed, hacked, whatever... # I would appreciate a note however if you are changing it or including # it in some software package so I know where to look for it. :-) # This program is designed to be used in conjunction with procmail # and with formail, which is part of the procmail package. # Suggested uses: an autoresponder, a spam rejector, a way to stop harassers # This program accepts RFC 822 mail from stdin, generates a replying # set of headers, including additional addresses which can be specified # on the command line, includes any text files, quotes the original e-mail # with COMPLETE HEADERS, and sends everything to stdout, which can be piped # into sendmail for transmission. # Sample .procmailrc recipe file for calling forrep: # # :0 E # * ^From:.*cyberpromo.com # | $MAILDIR/forrep [filenames] [recipients] \ # | $SENDMAIL -oi -t # # Upon invocation, forrep will determine if the arguements are filenames # or e-mail addresses which makes very good flexibility. :-) # If you want to BCC a copy of the resulting e-mail to yourself, change # that last line to be: # # | $MAILDIR/forrep [filenames] [recipients] \ # | $FORMAIL -I "BCC: $USER" | $SENDMAIL -oi -t # Caution: I *STRONGLY* suggest running this by hand and making sure that # this works on your system BEFORE you go and implement this into procmail # as nasty things could happen #sets up our temp files # change the date command to suit your system, this should work though... TMP=/tmp/autoreply.`date +%H%M%S` touch $TMP chmod 600 $TMP TMP2=/tmp/autoreply.file.`date +%H%M%S` touch $TMP2 chmod 600 $TMP2 # copies the e-mail message into this file cat >$TMP # "null string" TO="null" # who am I? For the X-loop: header SELF=dmuth@ot.com # location of formail, this may need to be changed FORMAIL="./formail" # this should sort out the arguements between files and e-mail addresses while test $# -gt 0 do if test -r $1 then cat $1 >>$TMP2 else if test "$TO" = "null" then TO=$1 else TO="$TO, $1" fi fi shift done # output the headers, if test "$TO" = "null" then cat $TMP |$FORMAIL -rt \ -I"X-Loop: $SELF" -I"X-Autoresponder: forrep 1.0" else cat $TMP |$FORMAIL -rt -I"Cc: $TO" \ -I"X-Loop: $SELF" -I"X-Autoresponder: forrep 1.0" fi # output the files cat $TMP2 # quote the e-mail message and output it sed s/"^"/">"/ <$TMP # cleanup rm -f $TMP rm -f $TMP2 # let's get out of here!