procmailrc3

~$ cat .procmailrc
INCLUDERC=/mnt/vacation/me/rc.vacation

:0 Whc: msgid.lock
| formail -D 16384 msgid.cache

:0
* (To|cc|from|Delivered-To|CC|From):.*[email protected]
{
:0c:
[email protected]
:0
Maildir/.enquiry/
}
#Maildir/.enquiry/

BLACKLISTED = `formail -xFrom -xSender -xReply-To -xReturn-Path -xReceived | \
egrep -i -f ~/black.lst`

:0
* ! BLACKLISTED ?? ^^^^
Maildir/.Spam/

:0
* ? formail -c -xFrom -xSender -xReply-To -xReturn-Path -xReceived | \
sed “s/[[:space:]]for .*$//g” | egrep -is -f ~/white.lst
Maildir/

:0 H
* ^X-Spam-Status: Yes
{
:0c:
[email protected]
:0
Maildir/.Spam/
}
#Maildir/.Spam/

:0 H
* ^X-Spam-Flag: YES
Maildir/.Spam/

SENDERIP = `formail -c -XReceived | grep “by some.where.out.there” | grep -v “from some.where.out.there” | \
sed “s/^Received: from .*\[\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\)\].*by some.where.out.there.*$/\1/”`

:0
* ! SENDERIP ?? ^^[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*^^
{
SENDERIP =
}

:0
* ! SENDERIP ?? ^^^^
{
SENDER_REVERSED = `expr “$SENDERIP” | \
sed “s/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\4.\3.\2.\1/”`

KNOWNOFFENDER = `host “$SENDER_REVERSED”.sbl-xbl.spamhaus.org | \
sed “s/^.*\(127\.0\.0\.[0-9]*\)$/\1/”`

:0
* KNOWNOFFENDER ?? ^^127.0.0.[0-9]*^^
Maildir/.Spam/
}

:0
* ! SENDERIP ?? ^^^^
{
SENDER_DYNAMIC = `host “$SENDER_REVERSED”.dul.dnsbl.sorbs.net | \
sed “s/^.*\(127\.0\.0\.[0-9]*\)$/\1/”`

:0
* ! SENDER_DYNAMIC ?? ^^127.0.0.[0-9]*^^
{
SENDER_DYNAMIC =
}
}

:0
* ^Return-path.*@\/[-a-zA-Z0-9_.]*
{
RETURN_PATH_HOST = $MATCH
}

:0
* ! SENDER_DYNAMIC ?? ^^^^
{
RESOLVED = `host -a “$RETURN_PATH_HOST” | grep “$SENDERIP”`

:0:
* RESOLVED ?? ^^^^
Maildir/.Junk/
}

:0
* ^Return-path.*([^.]yahoo\.|@aol\.co|compuserve|@mail\.com|lycos|excite\.com|@usa\.net|hotmail|msn\.com)

{
:0
* RETURN_PATH_HOST ?? ^^msn.com^^
{
RETURN_PATH_HOST=”(msn.com|hotmail.com)”
}

:0
* $ ! Received.*[^=][ ]*${RETURN_PATH_HOST}
Maildir/.Junk/
}

:0 # forward if security
* ^Subject:.*[EDM].*
Maildir/.Spam

:0 B
* my-name-yay
{
:0c:
[email protected]
:0
Maildir/
}
Maildir/

:0 HB
* (Password expiring in|Please change your password|If you see negative days)
Maildir/.Password/

:0 HB
* ^From.*(announcement|webmaster)@some.where.out.there
* Alanine|Cysteine|Glycine|Histidine
{
:0c:
| (formail -r -A”X-Loop: [email protected]” -I”From: [email protected]” -I”To: [email protected]”; cat help.txt ) | $SENDMAIL -t
:0
Maildir/
}

:0 # forward if security
* ^Subject:.*[IT Security Advisory].*
* !From.*[email protected]
{
:0c:
! [email protected],[email protected]
:0
Maildir/.outthere
}

# All other mail goes into the main inbox.
:0
{
:0c:
[email protected]
:0
Maildir/
}
#Maildir/