#!/bin/ksh # This was actualy written for ksh, but seems to work with sh on my HP system # If you don't have ksh, try changing the above to sh # simple Mailfiltering program for generic mail filtering. # # Change the 'yourusername', 'yourhomedirhere' and 'yourmailspoolfile' # entries below. # then save mailfilter in your own bin directory. # # create a .forward file in your home directory containing only the following: # "| /yourhomedirhere/bin/mailfilter" # # IMPORTANT: sendmail does NOT appreciate creativity in your .forward # file!! The format MUST be as above, with double quotes and the # single space after the pipe symbol!! Incorrect addresses can cause sendmail # to quietly dump your mail. # # Send yourself a test message to be sure you get it and you're all set to go. # # Problems: there may be a problem writing directly to the spool file without a # lock on it. In practice I haven't had trouble with this since I don't keep # a different copy of the file, just do a straight dump to it. # Solution: I changed the script to instruct sendmail to resend directly # to your mail spooler file. Most sendmails should support this feature. # If it doesn't, you can always use the old method. # YOURUSERNAME=yournamehere YOURHOMEDIR=yourhomedirhere YOURMAILSPOOLFILE=/var/mail/yourmailspoolfile dontmail=0 cat >/tmp/mailsearch.$$ grep "Subject" /tmp/mailsearch.$$ |head -n 1 >/tmp/mailsubject.$$ # this part actually searches for the file to extract tagger=`grep -i -c "xearthmarkers.UU" /tmp/mailsubject.$$` if (( $tagger > 0 )) then dontmail=1 cd $YOURHOMEDIR uudecode /tmp/mailsearch.$$ # file decodes as 'xearthmarkers', probably want it invisible: mv xearthmarkers .xearthmarkers fi # actually send the message by dumping it in your mail spool file if (( $dontmail < 1 )) then # cat >$YOURMAILSPOOLFILE # if your sendmail doesn't support this, you can use the above, # but file blocking is not implemented sendmail -oi \\$YOURUSERNAME