|
# which maildir is to use?
|
|
|
|
# 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"
|
|
}
|
|
}
|
|
|
|
|
|
# move spam to .Junk folder
|
|
DESTDIR="$MAILDIR"
|
|
|
|
# Here go the filter rules...
|
|
|
|
if ( /^X-Rspamd-Bar:\s\+\+\+[+]/:h )
|
|
{
|
|
DESTDIR="$MAILDIR/.Junk"
|
|
}
|
|
elsif ( /^List-ID:.*/:h )
|
|
{
|
|
DESTDIR="$MAILDIR/.newsletters"
|
|
}
|
|
elsif ( /^Delivered-To:.*-*@.*$/:h )
|
|
{
|
|
DESTDIR="$MAILDIR/.services"
|
|
}
|
|
|
|
|
|
# Hierarchically create DESTDIR if it does not already exist.
|
|
HIER="$DESTDIR"
|
|
CONTINUE=1
|
|
while ( $CONTINUE && $HIER =~ /^(.*\/(\.[^.]+)*)(\.[^.]+)$/ )
|
|
{
|
|
if ( $MATCH3 ne ".INBOX" )
|
|
{
|
|
`test -d "$MATCH"`
|
|
if ( $RETURNCODE == 1 )
|
|
{
|
|
`maildirmake "$MATCH"`
|
|
}
|
|
else
|
|
{
|
|
CONTINUE=0
|
|
}
|
|
}
|
|
HIER=$MATCH1
|
|
}
|
|
|
|
# Deliver mail. If SILENT_DESTDIR is set, mark all mail in
|
|
# DESTDIR as read.
|
|
if ( $SILENT_DESTDIR )
|
|
{
|
|
# mark as read
|
|
cc "$DESTDIR"
|
|
`find "$DESTDIR/new/" -mindepth 1 -maxdepth 1 -type f -printf '%f\0' | xargs -0 -I {} mv "$DESTDIR/new/{}" "$DESTDIR/cur/{}:2,S"`
|
|
exit
|
|
}
|
|
else
|
|
{
|
|
to "$DESTDIR"
|
|
}
|