From: "Douglas J. Hunley" <root@hunley.homeip.net>

Below is most of my current procmailrc file. I sprinkled with comments where appropriate. If you gurus could check it over and suggest alternatives, improvemtns, etc. I'll keep track of everything in this thread and post a 'community procmail practices' file afterword.

Some notes:
$DEFAULT is your default mail file (/var/spool/mail/userid)

At any point in this fille you can have the mail delivered to somewhere else. Another file, a directory, whatever. I choose to leave everything in the mail spool, and then have kmail fiter is into folders. You can do it any other way you want..
 

----------- Begin procmailrc -------------------
# force some sane values
SHELL=/bin/sh
PATH="/usr/local/bin:/usr/bin:/usr/local/sbin:/bin:/sbin:/usr/sbin"

# these two are for the junkmail program (http://junkfilter.zer0.org)
PMDIR=$HOME/.procmail
JFDIR=$HOME/.procmail

# where does possible spam go for our later review
JUNKMAIL=$HOME/junkmail

# the null device for things we know are spam
NULL=/dev/null

# where should procmail log to (you can later run 'mailstat $PMDIR/log' to
get stats on what procmail did)
LOGFILE=$PMDIR/log

# what do we write to the log (default is everything)
LOGABSTRACT=all

# use verbose logging (useful for debug, otherwise it's way to much info)
VERBOSE=no

# where is formail
FORMAIL=/usr/bin/formail

#where is mimencode
MIMENCODE=/usr/local/bin/mimencode

# check every email that comes in against the msgid.cache file and if it is a
duplicate, through it out. if it's not, add the message id to the cache file
# also, keep the cache file limited to 16k
:0 Wh: $PMDIR/msgid.lock
| $FORMAIL -D 16384 $PMDIR/msgid.cache
# this rule only gets run if the immeditately prceding rule is true
:0 a:
$NULL

# Fix subjects so they don't have all those 'Re: re: RE:'
# and 'Fwd: Fw: Fwd:' things in them cause it's damn annoying to not be able
to see the real subject
SUBJECT=`$FORMAIL -xSubject: |/usr/bin/sed s/.R\[eE\]://g`
:0fhw
|$FORMAIL -I"Subject: $SUBJECT"
SUBJECT=`$FORMAIL -xSubject: |/usr/bin/sed s/.F\[wW\]://g`
:0fhw
|$FORMAIL -I"Subject: $SUBJECT"

# Preconvert all plain-text mail in certain encoded
# MIME formats into a more compact 8-bit format which can be
# used and displayed more easily
:0
* ^Content-Type: *text/plain
{
:0 fbw
* ^Content-Transfer-Encoding: *quoted-printable
| $MIMENCODE -u -q

:0 Afhw
| $FORMAIL -I "Content-Tranfer-Encoding: 8bit"

:0 fbw
* ^Content-Tranfer-Encoding: *base64
| $MIMENCODE -u -b

:0 Afhw
| $FORMAIL -I "Content-Transfer-Encoding: 8bit"
}

# Convert old-style PGP messages to MIME
:0
* !^Content-Type: multipart/
* !^Content-Type: application/pgp
{
:0 fBw
* ^-----BEGIN PGP MESSAGE-----
* ^-----END PGP MESSAGE-----
| $FORMAIL \
-i "Content-Type: application/pgp; format=text; x-action=encrypt"

:0 fBw
* ^-----BEGIN PGP SIGNED MESSAGE-----
* ^BEGIN PGP SIGNATURE-----
* ^END PGP SIGNATURE-----
| $FORMAIL \
-i "Content-Type: application/pgp; format=text; x-action=sign"
}

# Stuff that gets automatically responded to (neat trick!)

# turn off logging temporarily
LOGABSTRACT=no

# if someone emails us with 'fetch key' in te subject, bounce a copy of our
PGP key back to them
:0 h:
# message is not from the mail system itself
* !^FROM_DAEMON
# and does not have our bogus header
* !^X-Loop: foo\@bar\.com
# and is sent to one of our email addresses
*
^To:.*(root\@hunley\.homeip\.net|doug\@hunley\.homeip\.net|dhunley\@columbus\.rr\.com)
* ^Subject:.*fetch\ key
| ($FORMAIL -r -A 'From: "Douglas J. Hunley" <doug@hunley.homeip.net>' \
-i "Subject: PGP Key (Auto-Reply)" \
-A "X-Loop: foo@bar.com" ; \
/usr/bin/cat /opt/apache/htdocs/public.gpg && echo && /usr/bin/cat
/root/dotsignc) |\
/usr/sbin/sendmail -oi -t

# if someone emails us with 'fetch resume' in the subject, bounce a copy of
our resume to them
# (see description above)
:0 h:
* !^FROM_DAEMON
* !^X-Loop: foo\@bar\.com
*
^To:.*(root\@hunley\.homeip\.net|doug\@hunley\.homeip\.net|dhunley\@columbus\.rr\.com)
* ^Subject:.*fetch\ resume
| ($FORMAIL -r -A 'From: "Douglas J. Hunley" <doug@hunley.homeip.net>' \
-i "Subject: Current Resume (Auto-Reply)" \
-A "X-Loop: foo@bar.com" ; \
/usr/bin/cat /opt/apache/htdocs/resume.txt && echo && /usr/bin/cat
/root/dotsignc) | \
/usr/sbin/sendmail -oi -t

# Send MS attachments to /dev/null
# if you send us email with an attachment of type
'exe,vbs,shs,com,pif,bat,src' it gets trashed and you get a notice
:0 HB
* !^FROM_DAEMON
* !^X-Loop: foo\@bar\.com
* ^Content-Disposition: attachment;
*filename=".*\.(exe|vbs|shs|com|pif|bat|src)"
| ($FORMAIL -r -A 'From: "Douglas J. Hunley" <doug@hunley.homeip.net>' \
-i "Subject: Your message (Auto-Reply)" \
-A "X-Loop: foo@bar.com" ; \
echo "Your message contained some form of MS Windows executable and was
automatically deleted (unread). " && /usr/bin/cat /root/dotsignc) | \
/usr/sbin/sendmail -oi -t
:0 a:
$NULL

# turn logging back on
LOGABSTRACT=all

# Stuff that gets forwarded to others (and copied to us)
:0
* ^Subject:.*\[HilliardGreen\]
{
:0 c
!someone@somewhere.net

:0
$DEFAULT
}

# People who are on blacklisted sites that I want to receive mail from
:0 :
* ^From:.*(peck_d\@bellsouth\.net|wimonwan\@hotmail\.com)
$DEFAULT

# ---- mailing lists and other stuff ----

# Abacus announce mail list
# (we check the To field)
:0 :
* ^To:.*abacus-announce\@psionic\.com
$DEFAULT

# Apache mailing list
# (we check the To, Cc, Bcc, From, Reply-To, and Sender so we catch posts to
the list and messages from the list software itself)
:0 :
* ^(To:|Cc:|Bcc:|From:|Reply-To:|Sender).*apache\@moongroup\.com
$DEFAULT

# KDE mail lists
# (here we actually check for 2 different email addresses and group them
together)
:0 :
*
^(To:|Cc:|Bcc:).*(kde\@lists\.netcentral\.net|kde-user\@lists\.netcentral\.net)
$DEFAULT

# KICQ mail lists
# (ditto but for 3 addresses)
:0 :
*
^(To:|Cc:|Bcc:).*(kicq-announce\@lists\.sourceforge\.net|kicq-dev\@lists\.sourceforge\.net|icqlib-dev\@lists\.sourceforge\.net)
$DEFAULT
# ---- end mailing lists ----

# ---- Call junkfilter ----
# this is how to use multiple procmail rule files
INCLUDERC=$JFDIR/junkfilter

# Take action if junkfilter caught a junkmail.
# note that JFSTATUS gets set based on rules in the above include file
# and our "junk" mail gets written to $HOME/junkmail for our review
:0
* JFEXP ?? .
{
:0 f
* JFSTATUS ?? 1
| $FORMAIL -i "X-junkfilter: $JFVERSION" -i "X-Spammer: $JFEXP"

:0 E :
| $FORMAIL -i "X-junkfilter: $JFVERSION" \
-i "X-Spammer: $JFEXP" >> $JUNKMAIL

}

# ---- end of junkfilter ----

# misc SPAM rules

# Grab the To: and From: headers
To=`$FORMAIL -zx To:`
CC=`$FORMAIL -zx Cc:`
FROM=`$FORMAIL -zX From: | $FORMAIL -zrx To:`

# Catch mail that is sent to "friends" or "you"
# and send it to junkfile for review
:0 :
* ^TO.*( |<|,)(fr(|ie|ei)nd(s)?|you)@
$JUNKMAIL

# Catch mail with no To: and no Cc:
# ditto
:0 :
* TO??^S
* CC??^$
$JUNKMAIL

# Catch purely numeric addresses
# ditto
:0 :
* ^From:.*( |<)[0-9]+@
$JUNKMAIL

# Bogus Pegasus header
#ditto
:0 :
* ^Comment: Authenticated sender is
* ! ^X-Mailer: Pegasus
$JUNKMAIL

# Bad message ids
# ditto
:0 :
* ^Message-Id:.*<[^@]*>
$JUNKMAIL

# "Our research indicates" crap
# ditto
:0 B:
* (our|my) research indicates
$JUNKMAIL

# Multi-level marketing scams
# throw these away
:0 B:
* multi(-| )?level marketing
$NULL

# 2 dollar signs in the subject
# review these later
:0 :
* ^Subject:.*(\$\$)
$JUNKMAIL

# Spam that doesn't get caught
# for some reason. throw them away
:0
*
^(To:|Cc:|Bcc:|From:|Reply-To:|Sender:).*(greatbooks2002\@yahoo\.com|freebook6754\@yahoo\.com|csllovdd\@eatel\.net|startsmart\@hotmail\.com|pedcom\@n2sales\.com|study\@mujmail\.cz|find\@mailbox\.sk|msn\.com|opeuhdfsaf\@eon\.dk|julie20983\@att\.net|LD495\@maebashi-it\.ac\.jp|mailing\@marketinggnumerique\.com|ifo\@askidsgrow\.com|greatoffers\@gtmiadworx\.com|anderson2\@ig\.com\.br|AskCarl39\@aol\.com|GlobalServ35\@excite\.com|cybernetdeals\.webmaster\@verizon\.net|ifyxz\@male\.ru|catarinaamin\@arabia\.com||Bcc:|From:|Reply-To:|Sender:).*(greatbooks2002\@yahoo\.com|freebook6754\@yahoo\.com|csllovdd\@eatel\.net|startsmart\@hotmail\.com|pedcom\@n2sales\.com|study\@mujmail\.cz|find\@mailbox\.sk|msn\.com|opeuhdfsaf\@eon\.dk|julie20983\@att\.net|LD495\@maebashi-it\.ac\.jp|mailing\@marketinggnumerique\.com|ifo\@askidsgrow\.com|greatoffers\@gtmiadworx\.com|anderson2\@ig\.com\.br|AskCarl39\@aol\.com|GlobalServ35\@excite\.com|cybernetdeals\.webmaster\@verizon\.net|ifyxz\@male\.ru|catarinaamin\@arabia\.com|
asminkaur\@arabia\.com|sydaw\@fun\.21cn\.com|hk67hk89\@yahoo\.com|limmie939\@2hb\.net|RalphFranks\@vulcan\.alphanet\.ch|sales\@oraknowledge\.com|auspixcou\@public\.ytptt\.sd\.cn|gudboy2\@cwtel\.com|samgoody\@sg1\.keeneye\.net|7ni6kpoha1\@compuserve\.com|m4755\@mail\.com|yovzfjcbt\@hotbot\.com|subscribed-users\@web-news\.com|biotechstox28\@juno\.com|biotechinfo2007\@yahoo\.com|basuka\@altavista\.net|joel_jamison\@yahoo\.com|announce\@openoffice\.org|zenath1\@excite\.com|vhgro!
3iiu\@prodigy\.net)
$NULL

# End SPAM rules

# ---- whatever is left ----
:0:
$DEFAULT

---------- End procmailrc ------------------
searchSearch Index