Skip to content

Instantly share code, notes, and snippets.

@anagromataf
Created August 30, 2014 17:22
Show Gist options
  • Save anagromataf/17161e321552bd549472 to your computer and use it in GitHub Desktop.
Save anagromataf/17161e321552bd549472 to your computer and use it in GitHub Desktop.
Automatic Mailing-List Filtering
MAXSPAMSCORE="3"
logfile "$HOME/mailfilter.log"
# set default Maildir
MAILDIR="$HOME/Maildir"
# check if we're called from a .qmail-EXT instead of .qmail
import EXT
if ( $EXT )
{
# does a vmailmgr user named $EXT exist?
# if yes, deliver mail to his Maildir instead
CHECKMAILDIR = `dumpvuser $EXT | grep '^Directory' | awk '{ print $2 }'`
if ( $CHECKMAILDIR )
{
MAILDIR="$HOME/$CHECKMAILDIR"
}
}
## Lists & Groups
## --------------
# check folder structure
LISTDIR="$MAILDIR/.Listen"
`test -d $LISTDIR`
if( $RETURNCODE == 1 )
{
`maildirmake $LISTDIR`
}
# move all mail from lists to the folder /Listen/<list-id>
if ( /^List-Id:.*<(.*)>/:h )
{
LIST=$MATCH1
LIST=`echo $LIST | sed "s/\./-/g"`
`test -d "$LISTDIR.$LIST"`
if( $RETURNCODE == 1 )
{
`maildirmake "$LISTDIR.$LIST"`
}
to "$LISTDIR.$LIST"
}
#############################################################
# and finally, deliver everything that survived our filtering
to "$MAILDIR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment