[Dovecot] Namespace with a single mailbox (for spam)

Bill Landry billl at inetmsg.com
Mon Sep 11 20:11:11 EEST 2006


----- Original Message ----- 
From: "Tom Alsberg" <alsbergt at cs.huji.ac.il>

> Hi there.
>
> Perhaps this is answered somewhere, but a short search through the
> mailing list and Wiki yielded nothing.
>
> We have spam filtering set up for all users, with all messages over
> some spam threshold going to a separate mbox.  There is one directory
> containing the spam mboxes of all users (call it "/var/spool/spam",
> right now), with the spam box of a user residing in
> /var/spool/spam/<user>.
>
> I am trying to achieve that, in IMAP, each user will see his spam mbox
> as a folder named "SPAM" or something like that (possibly under some
> new namespace), without creating a symbolic link for each user.
>
> Is there any facility for that?
>
> Specifically, I do not want to create a single namespace pointing to
> the directory, since that will cause each user to have to access his
> spam folder under a different name (e.g. #spam.<user>), and users will
> also see (although not be able to read) others' spam folders.

Tom, are you using a sieve or delivery agent (procmail/maildrop) to handle 
final delivery to the IMAP folders based on the spam threshold?  If so, we 
use maildrop and include the following in our "/etc/maildroprc" config file"
#==========
# Deliver to Inbox or Spam box
if (/^X-Spam-Flag: YES/)
{
        `test -d $DEFAULT/.Spam`
        if( $RETURNCODE == 1 )
        {
                `/usr/local/bin/maildirmake -f Spam $DEFAULT`
                `echo "Spam" >> $DEFAULT/subscriptions`
        }
        exception {
                to "$DEFAULT/.Spam"
        }
        # if all else fails, do regular delivery
        exception {
                to "$DEFAULT"
        }
}
#==========

For us, this basically checks to see if the Spamassassin spam flag 
(X-Spam-Flag: YES) is found in the message headers, and if so, checks to see 
if the recipient has a "Spam" folder already defined, and if not, creates it 
and then delivers the message into the spam folder and adds "Spam" to the 
IMAP "subscriptions" files.  If anything fails along the way, it will 
instead send the message to the default inbox folder.

HTH,

Bill 



More information about the dovecot mailing list