# $Id$ # GNATS procmail file # # - MH style mail folders # - Use this instead of alias for "bugs" aliases instead of pipes so that we # can preprocess emails first # - First order of business, spam filtering. # - Spam filtering is available on mail server, but we want local control # - Add autoacks for queue submissions (Reply-to: nobody) # # Administrative email still should be aliased to "root" # # See also: procmail(8), procmailrc(5), procmailex(5), procmailsc(5), # formail(8), lynx(1), bzip2(1), gnats(7), queue-pr(8), mail-query # MAILDIR=$HOME/Mail SHELL=/bin/bash DEFAULT=inbox/. COMSAT=no MY_ADDR=gnats@BUGHOST.MYDOMAIN MY_XLOOP=$MY_ADDR YEAR_MONTH=`date +%Y-%m` MAXSIZE=51200 LOGABSTRACT=yes VERBOSE=no LOGFILE=procmail-${YEAR_MONTH}.log # Kill duplicates :0 Wh: msgid.lock | formail -D 8192 msgid.cache # Spam filtering before archiving :0 fw * ! ^X-Spam-Status: Yes | /usr/bin/spamc -s $MAXSIZE -d SPAMASSASSIN-HOST.MYDOMAIN # Attempt to archive and save to spam folder :0 * $ < $MAXSIZE * ^X-Spam-Status: Yes { :0 wc | /usr/bin/bzip2 -9 >> spam-${YEAR_MONTH}.mbox.bz2 :0 spam/. } # Compressed Archive if not spam and not too large :0 c * $ < $MAXSIZE * ! ^X-Spam-Status: Yes { :0 w | /usr/bin/bzip2 -9 >> received-${YEAR_MONTH}.mbox.bz2 :0 e backup/. } # Score Kill List -- positive score to kill # Only matching headers so far :0 H * -99^0 # Basic mailer daemon filtering * 100^0 ^FROM_DAEMON * 100^0 ^From.*(postmaster|mailer-daemon|root) * 100^0 ^Precedence:.*(bulk|junk) # VIRUSES and BANNED files * 100^0 ^From.*abuse@cbs\.umn\.edu * 50^0 ^Subject:.*(VIRUS|BANNED) # Spammers * 100^0 ^From.*webadmin@coastal\.gov\.bb * 100^0 ^From.*@bp\.com * 100^0 ^From.*\(via the vacation program\) * 100^0 ^From.*derek\.yikes@shaw\.ca * 100^0 ^From.*wseas_ece@canada\.com # Spam phrase matching * 100^1 ^Subject:.*NPSAS Initiative { :0 * ^Message-Id:\/.* # Already archived. Log message id for reference. { LOG="Killed Message-ID: $MATCH " } # Kill it :0 /dev/null } # Fix HTML-only email :0 * ! ^Content-Type: multipart/ * ^Content-Type: text/html { # Change body with lynx and append footer :0 fbw | (lynx -dump -force-html -stdin; echo ""; \ echo "-=-=[CONVERTED FROM HTML VIA LYNX]=-=-") # Prepend body header :0 Afbw | (echo "-=-=[CONVERTED FROM HTML VIA LYNX]=-=-"; cat -) # Change header content-type (preserve old) :0 Afhw | formail -i "Content-Type: text/plain" } # Route PR's to queuing program PR_REGEX='(bugs|help|webmaster|request)' :0 w * $ ^TO$PR_REGEX { # We've been getting very large files. We would like to reject these # with a friendly note. This is in bytes (50K). There is no copy # here, because we want to quell this email (and it's already # archived). :0 * $ > $MAXSIZE | ( formail -r ; cat toobig.txt ) | $SENDMAIL -oi -t # save to failed-queue :0 A failed-queue/. # Queue the problem :0 | /usr/lib/gnats/queue-pr -q # Save if failed queue-pr :0 e failed-queue/. } # Route mail queries through the mail-query program :0 w * ^TOquery-pr | /usr/lib/gnats/mail-query :0 e failed-query/. # Bounce mail addressed to gnats and gnats-admin to root user :0 fhw * $ ! ^X-Loop: $MY_XLOOP * ^TOgnats(-admin)? | formail -I"X-Loop: $MY_XLOOP" :0 a ! -oi root@MYDOMAIN # Default email box (inbox/.)