LDA autocreate/autosubscribe per namespace?

Andreas Ntaflos daff at pseudoterminal.org
Thu Jul 7 12:48:03 UTC 2016


Using Dovecot 2.2.25 and Pigeonhole 0.4.14. I can provide the output of 
doveconf -n if needed.

We use a moderately clever global Sieve script to create a read-only 
(using ACLs) backup/archive of all incoming and outgoing mails. Mail 
messages filtered this way are filed into folders in a namespace called 
"Backup", e.g. Backup/sent-backup/${year}/${month} and 
Backup/received-backup/${year}/${month}. The Sieve script in question 
can be found at the end of this message for reference.

Now obviously we generally want mailboxes to be created automatically, 
so we set

lda_mailbox_autocreate = yes

in dovecot.conf. We also want regular mailboxes, created by our users' 
own Sieve scripts, to be autocreated and autosubscribed, so we also set

lda_mailbox_autosubscribe = yes

in dovecot.conf.

But we *don't* want the Backup mailboxes to be subscribed automatically, 
because our users usually only need access to those when they want to 
restore messages accidentally deleted from their INBOX or other folders. 
So the idea is to keep these Backup mailboxes unsubscribed, which also 
saves lots of space and network traffic on the user side. When a user 
then wants to restore a deleted mail message they subscribe to the right 
Backup folder and copy the message back to their INBOX (and then 
unsubscribe again).

Is there a way to control autocreate/autosubscribe per namespace?

Currently it doesn't look that way, and 
lda_mailbox_autocreate/lda_mailbox_autosubscribe are valid globally.

The "Backup" namespace is configured this way:

namespace backup {
   hidden = no
   list = yes
   inbox = no
   location = maildir:~/Maildir-backup
   prefix = Backup/
   separator = /
   type = private
}

This is the Sieve script in 
/etc/dovecot/sieve.d/before/002-backup-mails.sieve:

require ["subaddress", "fileinto", "copy", "envelope", "imap4flags", 
"variables", "date", "mailbox" ];

if currentdate :matches "year" "*" { set "year" "${1}"; }
if currentdate :matches "month" "*" { set "month" "${1}"; }

# This makes use of sender_bcc_maps in Postfix
if envelope :detail "to" "sent-backup" {
     fileinto :flags "\\Seen" "Backup/sent-backup/${year}/${month}";
     stop;
}

# We only want to backup incoming mail if it is not marked as spam.
if header :contains "X-Spam-Flag" ["YES"] {
     discard;
     stop;
} else {
     fileinto :copy :flags "\\Seen" 
"Backup/received-backup/${year}/${month}";
}

Thanks,

Andreas


More information about the dovecot mailing list