Christopher B. Browne's Home Page
cbbrowne@acm.org

6. Mail Filtering

6.1. .maildelivery

This is used with the MH family of mail readers. It is not real sophisticated, but it's useful enough if your needs are limited.

6.1.1. How to activate it

  • If you use sendmail as the mail transport agent, create .forward containing: "|bin/sh -c 'exec >> /tmp/out 2>&1; /usr/lib/mh/slocal -user cbbrowne -verbose -debug"

  • If, like me, you use Qmail, a "more modern" mail transport agent, create .qmail containing: | /usr/lib/mh/slocal -user cbbrowne

6.1.2. Sample .maildelivery File

>Subject "Connect Log" | A "/usr/lib/mh/rcvstore +Logs" # CT = "Canada Trust" Subject "Portfolio Valuation" | A "/usr/lib/mh/rcvstore +CT" # Stuff from family & Anil goes to appropriate mailboxes From "coffee@ns.sympatico.ca" | A "/usr/lib/mh/rcvstore +Brownes/Brad" From "hbcsb@magi.com" | A "/usr/lib/mh/rcvstore +Brownes/Dad" From "apbalara@interactiv.com" | A "/usr/lib/mh/rcvstore +Friends/Anil" From "dmbrowne@cyberramp.net" | A "/usr/lib/mh/rcvstore +Brownes/Dave" From "dc2brown@undergrad.math.uwaterloo.ca" | A "/usr/lib/mh/rcvstore +Brownes/Doug" # Use Ifilter on the remainder... * - ^ ? /home/cbbrowne/bin/ifilter # And if it's not been hit just yet, toss it in the inbox # It also means that if ifilter should happen to crash # for some reason, the mail will *not* be lost; the failed status code # means that processing will fall out to this rule default - ^ ? "/usr/lib/mh/rcvstore +inbox"

6.2. procmail

procmail is included with all distributions of Linux that I know of.

6.2.1. Sample .procmailrc File

:0 c backup # Preserve all mail in backup files Just In Case... :0 ic | cd backup && rm -f dummy `ls -t msg.* | sed -e 1,32d` :0:.saplock * ^Sender: SAP R/3 Discussion * Subject: *BASIS | /usr/lib/mh/rcvstore +SAP/BASIS :0:.saplock * ^Sender: SAP R/3 Discussion | /usr/lib/mh/rcvstore +SAP :0:.alpha * ^Resent-From: axp-list | /usr/lib/mh/rcvstore +Alpha :0:.ntlug * ^Sender: owner-ntlug | /usr/lib/mh/rcvstore +Linux/NTLug :0:.general * ^From: | /usr/lib/mh/rcvstore +inbox #:0:.portfolio #* ^Subject: Portfolio #| /usr/lib/mh/rcvstore +CT # #:0:.debian #* ^Resent-From: debian-announce #| /usr/lib/mh/rcvstore +Linux/Debian # #:0:.dilbert #* ^Subject: New Dilbert #| /usr/lib/mh/rcvstore +dilbert

6.3. Ifile

This works in conjunction with MH/EXMH, providing a filter that examines your message refiling patterns in order to determine where future mail ought to go.

6.4. Other Email Filtering...

6.5. Email Filtering using Ifile

ifile uses a statistical approach called Naive Bayesian Filtering directed (at this point) at filtering mail into MH mail folders.

Ifile was designed for use in conjunction with MH for email. I have written Perl scripts that go through a news spool and pass news messages on to ifilter. I'm still in the experimental stages on this; at present it doesn't handle outgoing news very well. But it does provide fairly good message classification. Various forms of "spam" get quite accurately classified as such, so that it takes only a quick browse to "nuke the spam." I still have to complete the circle, turning at least portions of this back into news. (Maybe it's time to try out GNUS. )

6.6. Other Email Filtering Links

Google
Contact me at cbbrowne@acm.org