
"Damaged Justice" writes:
Would some kind soul out there be willing to instruct a novice in the mysteries of procmail? I've finally decided to start killfiling my mail as well as my news.
A fine idea. Procmail makes the Cypherpunks list infinitely more readable. 1) First, here's how to get it: ---------------------- A recent version can be picked up at various comp.sources.misc archives. The latest version can be obtained directly from the ftp-archive at: amaru.informatik.rwth-aachen.de (137.226.112.31) as compressed tar file: pub/unix/procmail.tar.Z <100KB or in compressed shar format: pub/unix/procmail.0?.Z ---------------------- 2) Build the procmail program and install it in a suitable location. I have no idea what your familiarity with UNIX and C is; you may want to have your sysadmin help you with this. Alternatively, you could use Alta Vista or equivalent to search for binaries for your system. 3) Create a file of procmail "recipes", which tell it how to process your mail. This file is called "$HOME/.procmailrc". Mine begins like this; fix up directory names as needed for your system: ----------------------- # # $HOME/.procmailrc - procmail recipe file # PATH=/usr/local/bin:/usr/ucb:/bin:/usr/bin:$HOME/bin/700o:$HOME/bin ME= janzen HOME= /Home/$ME LOGFILE= $HOME/.procmaillog MAILDIR= $HOME/Mail ORGMAIL= /usr/mail/$ME DEFAULT= $ORGMAIL TMP= $HOME/tmp SENDMAIL= /usr/lib/sendmail TMPFILE= $TMP/procmail.$$ LOCKFILE= $HOME/Mail/.procmail # toss out junk mail :1 ^Subject:.*unsubscribe /dev/null # sort mail from mailing lists into the proper folders :1 cypherpunks Cypherpunks ----------------------- The last part sorts all mail whose header contains the word "cypherpunks" into the folder $MAILDIR/Cypherpunks. Now the fun part -- writing your "recipes"! You can get as specific as you want: ----------------------- # kill a particular thread :2 ^To:.*cypherpunks@toad.com ^Subject:.*Workers of the /dev/null # ignore a particular user :2 cypherpunks patrickbc@juno.com /dev/null # I haven't tried this one, but any subject with too many consecutive # capitals is probably spam or worse. Separate it out, but don't toss # it just yet. :2 cypherpunks ^Subject:.*[A-Z][A-Z][A-Z][A-Z][A-Z][A-Z] ProbableSpam # search the whole message body, not just the headers, for probable spam :1HB ^dear friend ProbableSpam # put everything else in the incoming Cypherpunks mail folder :1 ^To:.*cypherpunks@toad.com NewCypherpunksMail ----------------------- Rules are evaluated in top-to-bottom order; first matching rule wins. Anything not matched ends up in your usual $ORGMAIL folder. 4) Run your incoming mail through procmail. To do this, most Unix systems let you create a file called "$HOME/.forward" with the following contents (including the quotes): "| IFS=' '; /usr/local/bin/procmail -p" (Replace "/usr/local/bin" with the directory in which you installed procmail.) 5) One thing to watch out for: procmail is executed on the machine which handles your mail. If this machine has a different architecture than your own machine, you must build procmail for the mail handling machine, not your own. Also, the permissions on your $HOME/.forward and $HOME/.procmailrc files must be set so that they are readable on the mail handling machine. If your home directory is NFS-mounted, this should happen automatically; otherwise, you may need to copy them to the mail handling machine manually. Finally, the procmail process may not have your userid, so you must make these files world-readable: chmod 644 $HOME/.forward $HOME/.procmailrc For the first day or two, check your $HOME/.procmaillog file frequently to see whether there are any problems. Check with your sysadmin to make sure that your mail isn't ending up "all over the floor". Send yourself mail to test "recipes". 6) Once it's running smoothly, you can get fancy and run the following shell script, which reads the $HOME/.procmaillog file and produces a nice summary, sorted by mail folder: ------------------------------------------------------------------------------- #!/bin/sh # Summarize the ~/.procmaillog file LOGFILE=${LOGFILE:=$HOME/.procmaillog} echo "Subject: Procmail Summary" echo " " sort ${LOGFILE} | /usr/bin/awk ' /^ Folder:/ { folder = $2; nbytes = $3; msgcount[folder] += 1; totalbytes[folder] += nbytes; } END { for (folder in msgcount) printf "Folder %s:\tsaved %d messages (%d bytes)\n", \ folder, msgcount[folder], totalbytes[folder]; } ' if [ "$1" = "-clear" ]; then rm -f $LOGFILE; fi ------------------------------------------------------------------------------- To arrange to have it run daily, I use the following crontab entry: 0 7 * * * /Home/janzen/bin/pmsumm.sh -clear | elm -s "Procmail Summary" janzen which means, "At 7:00AM every morning, run the pmsumm.sh script, use the Elm mailer to mail the output to me, and then clear $HOME/.procmaillog". See the "cron" man page for your system, and/or talk to your sysadmin, since this varies among different flavors of Unix. Hope this helps... -- Martin Janzen janzen@idacom.hp.com