Create custom mailboxes with dovecot

dovecotmailboxsieve

I'm trying to setup dovecot + sieve plugin. I'm suing the Maildir format. I use Thunderbird to read the emails so i don't need a webmail on my server. The basic config works fine but now I want to add some rules in sieve to redirect some mails, like this one for example :

require ["envelope", "fileinto"];
if envelope :is "from" "test@mydomain.com" {
    fileinto "Test";
}

But sieve can't find the "Test" dir so it puts it into "Inbox". /var/log/syslog output :

dovecot: lda(test@mydomain.com): Error: sieve: msgid=<[...]>: failed to store into mailbox 'Test': Mailbox doesn't exist: Test
dovecot: lda(test@mydomain.com): sieve: msgid=<[...]>: stored mail into mailbox 'INBOX'

So I tried adding a mailbox manually (but ideally i would want it to be automatic when sieve request a new mailbox) by using this conf in dovecot :

 namespace inbox {
  inbox = yes
  location = 
  mailbox Drafts {
    auto = subscribe
    special_use = \Drafts
  }
  mailbox Junk {
    auto = subscribe
    special_use = \Junk
  }
  mailbox Sent {
    auto = subscribe
    special_use = \Sent
  }
  mailbox Test {
    auto = subscribe
  }
  mailbox Trash {
    auto = subscribe
    special_use = \Trash
  }
  prefix = 
}

Like that the mailbox is created upon reception of a mail and the mail is stored in ~/mail/Test/new/ but I can't find the folder/mailbox "Test" in Thunderbird. Every other mailbox appears correctly as a folder in Thunderbird but not the new one.

What am i doing wrong ? I can't find any example of dovecot config where people use custom mailboxes (only the few default ones). Is it even possible with dovecot ? Even better : is there a way to automate creation of mailbox when sieve need a new one ?

Best Answer

Use the :create parameter of the mailbox sieve capability (don't forget to require it!):

require ["envelope", "fileinto", "mailbox"];
if envelope :is "from" "test@mydomain.com" {
    fileinto :create "Test";
}
Related Topic