procmail is a Unix tool for filtering email. Typically one creates a ~/.forward file such as:
"|IFS=' '&&exec /triumfcs/bin/procmail ||exit 75 #JoeUser"(replacing "JoeUser" with your own username), and creates a ~/.procmailrc file with various procmail commands. This has the effect of taking your email from the incoming mail spool and sorting it into a number of separate in-boxes. Some mail tools, such as Pine, and some mail notification tools such as newmail may be configured to use multiple in-boxes. For example, the following in ~/.pinerc sets up separate boxes for www-talk, junk, and valid mail:
incoming-folders=WWW-Talk mail/www.in, Mail mail/valid.in, IETF mail/junk.in
:0 * X-Spam-List mail/spamYou may wish to add the following line to .pinerc if using Pine:
incoming-folders=Spam mail/spam(add more entries for mailing lists, etc.)
:0 * .*www-talk@w3 www-talk.inThe wildcard ensures they go in the box regardless of whether they are to the list directly, to someone else Cc: the list, or to named recipients and also the list.
Broadcasters of junk email have adopted a number of strategies to ensure that you read their messages, while making it difficult for irate recipients to reply. One would usually like "important" mail to receive more priority than junk mail. The following is an outline for dealing with unwanted mail:
When you subscribe to a mailing list or listserv, note the typical form of messages from the list and craft a procmail filter to sort it. Occasionally mail may arrive with a header using an alias of the listserv (e.g. mail.xxx.com instead of xxx.com).
You may wish to treat all mail from the triumf.ca domain as valid. It wouldn't do to discard a memo from your boss! You might include a line such as
:0 * ^From:.*triumf.ca valid.in
You may decide that all mail from rodent.com is junk. You can file it using a similar filter:
:0 * ^From:.*rodent.com junk.in
From: firstname.lastname@example.org To: email@example.com Subject: Hi
From: firstname.lastname@example.org To: email@example.com Subject: Your message
From: firstname.lastname@example.org To: email@example.com Subject: I think you should see this
From: firstname.lastname@example.org To: email@example.com Subject: Your recent posting
:0 * !^To:.*firstname.lastname@example.org|^cc:.*email@example.com junk.inwhich says that any mail NOT To you or Cc you goes in "junk.in". You may like to filter mail apparantly from yourself or postmaster, too:
:0 * !^From:.*firstname.lastname@example.org|From:.*email@example.com junk.inNote that you may get valid mail from "postmaster", depending on your mail configuration, if you send mail to a bad local address, so be careful.
PATH=$HOME/bin:/usr/bin:/bin:/usr/local/bin:. MAILDIR=$HOME/mail # You'd better make sure it exists DEFAULT=$MAILDIR/valid.in LOGFILE=$MAILDIR/from LOCKFILE=$HOME/.lockmail SENDMAIL=/usr/sbin/sendmail # typical mailing list folder :0 * .*www-talk@w3.*|.*www-html@w3.* www-talk.in # mailing list I want in the valid box :0 * .*firstname.lastname@example.org valid.in # various known spam domains :0 * ^From:.*hotmail.com|^From:.*nobody@nobody|^From:.*savetrees.com|^From:.*t-3net.com|^From:.*answerme.com|^From:.*t-1net.com junk.in # NOT known valid domains :0 * !^To:.*triumf.ca|^cc:.*triumf.ca|^From:.*triumf.ca junk.in # everything else falls through to DEFAULT (valid.in)
Sundry sites dedicated to controlling junk email: