Created
August 30, 2014 17:22
-
-
Save anagromataf/17161e321552bd549472 to your computer and use it in GitHub Desktop.
Automatic Mailing-List Filtering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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