• Dear Pleskians! The Plesk Forum will be undergoing scheduled maintenance on Monday, 7th of July, at 9:00 AM UTC. The expected maintenance window is 2 hours.
    Thank you in advance for your patience and understanding on the matter.

How to get filters to run automatically

D

djbwise

Guest
How to get filters to run automatically (server side)

Is it possible to get the filters(the ones you set in horde webemail) to run automatically, even when webmail is not open? This would be sweet, and let the server side filter work for multiple IMAP clients. Seems it should work this way by default even.
 
Originally posted by djbwise
Is it possible to get the filters(the ones you set in horde webemail) to run automatically, even when webmail is not open? This would be sweet, and let the server side filter work for multiple IMAP clients. Seems it should work this way by default even.

The simple answer is to install maildrop.

this is run when the users .qmail file is parsed

here is an example of a users .qmail file locate at:

/var/qmail/mailnames/DOMAIN.COM/USERNAME/.qmail

with permissions
-rw------- 1 popuser popuser 452 Jun 4 16:17 /var/qmail/mailnames/DOMAIN.COM/USERNAME/.qmail


Code:
| if [ -z "$SA" ]; then export SA=1; /usr/local/psa/bin/psa-spamc -u [email][email protected][/email] -U /tmp/spamd_light.sock > spamcheck$$; if [ -s spamcheck$$ ]; then /var/qmail/bin/qmail-local "$USER" "$HOME" "$LOCAL" "" "" "$HOST" "$SENDER" "$DEFAULT" < spamcheck$$; retval=$?; rm -f spamcheck$$; [ $retval = 0 ] && exit 99; exit $retval; fi; rm -f spamcheck$$; fi # ACCEPT UCE
| true
| /var/qmail/bin/preline /usr/bin/maildrop /etc/mail/mailfilter-extended


the last line of this example forces maildrop to read its filtering rules from /etc/mail/mailfilter-extended.

A working example to filter for spam is show:

Code:
SHELL="/bin/sh"
import EXT
import HOST

import USER
import HOME
import LOCAL
import HOST
import SENDER
import DEFAULT



VPOP="| $VDELIVERMAIL '' bounce-no-mailbox"

MAILDIRMAKE="/usr/bin/maildirmake"
DELIVERQUOTA="/usr/bin/deliverquota"
BOUNCESAYING="/var/qmail/bin/bouncesaying"

MAXMAILSIZE=512000

#logfile "/var/log/maildrop.log"
logfile "maildrop.log"

log " ";
log "====  BEGIN maildrop processing for $EXT@$HOST ==="

log "$USER $HOME $LOCAL $HOST $SENDER $DEFAULT"

#MAILDIRQUOTA=`/usr/bin/head -n1 Maildir/maildirsize`

if ( /^X-Spam-Status: Yes/)
{
        `test -d Maildir/.Spam`   # make sure .Spam folder exists
        if( $RETURNCODE == 1 )
        {
                log "  creating Maildir/.Spam "
                `$MAILDIRMAKE Maildir/.Spam`
                `echo "INBOX.Spam" >> Maildir/courierimapsubscribed`
        }

        log "  SPAM: attempting quota delivery to Maildir/.Spam"
        exception {
                xfilter "$DELIVERQUOTA Maildir/.Spam"
                log "DELIVER TO SPAM DIR"
                log "$DELIVERQUOTA Maildir/.Spam"
        }

        if( $RETURNCODE == 77)
        {
                log "  QUOTA FAILURE: bouncesaying ' over quota'"
                to "|$BOUNCESAYING 'This mail cannot be delivered. $DEFAULT is over quota'"
        }
        log "=== END ===  success"
        exit
}


log "Delivering clean mail to Maildir/"
xfilter "$DELIVERQUOTA Maildir"
log "=== END ==="
log ""
exit;

numerous examples exist online.

have fun
 
But how would this run with the horde/ingo filters? I want users to be able to set rules in horde webmail and have them filter when the message comes in.
 
Back
Top