Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have set up Dovecot on my Postfix mailserver. My mailserver is using Maildir format:

home_mailbox = Mail/inbox/

A user's Mail directory looks like this:

$HOME/Mail/inbox
$HOME/Mail/drafts
$HOME/Mail/sent
$HOME/Mail/trash

I have set up mailboxes in Dovecot accordingly

mail_location = maildir:~/Mail

namespace inbox {
  mailbox drafts {
    special_use = \Drafts
  }
  mailbox sent {
    special_use = \Sent
  }
  mailbox trash {
    special_use = \Trash
  }
}

Now, the problem is, Dovecot does not use the mailboxes as defined, but creates its own mailboxes named with a . in front and with first letter capital:

$HOME/Mail/.Drafts
$HOME/Mail/.Sent
$HOME/Mail/.Trash

Further, instead of using $HOME/Mail/inbox as inbox, it uses $HOME/Mail as inbox. i.e. it created the cur/new/tmp directories directly in $HOME/Mail/, rather than using the existing $HOME/Mail/inbox:

$HOME/Mail/cur
$HOME/Mail/new
$HOME/Mail/tmp

SUMMARY:

explained briefly, what I need is the following:

I have an existing Maildir folder structure where Postfix delivers mail, plus the usual folders (drafts, sent, ...):

$HOME/Mail/inbox/{cur,new,tmp}
$HOME/Mail/drafts/{cur,new,tmp}
$HOME/Mail/sent/{cur,new,tmp}
$HOME/Mail/trash/{cur,new,tmp}

How can I tell Dovecot to use the correct directories?

share|improve this question
1  
It looks like you're mixing two things, the mapping between RFC 6154 tags and dovecot mailboxes and the mapping between dovecot mailboxes and filesystem directory names. Those are two different things. –  Pavel Šimerda Jul 6 at 19:25
    
@Pavel Šimerda - OK, thank you. Do you have a solution how to achieve what I need ? –  Martin Vegter Jul 8 at 17:31
    
I don't know what you're trying to achieve. In my opinion the best way is to deliver mail always through Dovecot and then you don't have any problem. As a bonus, you can then use Dovecot's SIEVE filters which are really handy. –  Pavel Šimerda Jul 9 at 20:50

3 Answers 3

up vote 1 down vote accepted
+300

By default Dovecot uses Maildir++ directory layout for organizing mailbox directories. This means that all the folders are directly inside ~/Maildir directory, and:

~/Maildir/new, ~/Maildir/cur and ~/Maildir/tmp directories contain
the messages for INBOX.

You can read more about the layout here

Thus what you complain about is standard behavior. You can change the layout nevertheless, by using the LAYOUT and INBOX options. To have cur, new, tmp inside Inbox as you require:

$HOME/Mail/inbox/{cur,new,tmp}

you could specify the following option in /etc/dovecot/conf.d/10-mail.conf:

mail_location = maildir:~/Mail:INBOX=~/Mail/inbox:LAYOUT=fs
share|improve this answer
    
that works great ! –  Martin Vegter Jul 11 at 15:53
    
Good answer. But I still think it may be better to use dovecot's deliver to be able to make use of dovecot filtering features and stuff like that, as described in my answer. –  Pavel Šimerda Jul 12 at 19:29

Modify your mail_location as follows.

mail_location = maildir:~/Mail:LAYOUT=fs

Ref: Dovecot Docs

  • ~/Maildir/new, ~/Maildir/cur and ~/Maildir/tmp directories contain the messages for INBOX.
  • ~/Maildir/.folder/ is a mailbox folder
  • You can also optionally use the fs layout by appending :LAYOUT=fs to mail_location. This makes the folder structure look like: ~/Maildir/new, ~/Maildir/cur and ~/Maildir/tmp directories contain the messages for INBOX, just like with Maildir++. ~/Maildir/folder/ is a mailbox folder
share|improve this answer
    
but I need inbox to be in ~/Maildir/inbox/new not ~/Maildir/new. Also, appending :LAYOUT=fs only changes the names of other folders from .Draft to Draft. But my folders have lower case letters, i.e. draft. Is there any way to configure this? –  Martin Vegter Jul 7 at 8:14

The best way to work with dovecot maildirs is to always access them through tools packaged with dovecot. The combination of postfix and dovecot for virtual mailboxes follows.

This is not an answer to how to configure dovecot to understand postfix maildirs but rather an alternative way to work with e-mail directories. You can rather easily transition to this way by simply moving around the files so that everything resides where dovecot expects it.

/etc/postfix/master.cf

dovecot   unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${recipient}

/etc/postfix/main.cf:

virtual_transport = dovecot
virtual_mailbox_domains = hash:/etc/postfix/virtual/domains

/etc/postfix/virtual/domains:

example.com    none
example.net    none

(Don't forget to run postmap on the file.)

/etc/dovecot/dovecot.conf:

auth default {
    mechanisms = plain
    userdb static {
        args = uid=vmail gid=vmail home=/var/mail/%d/%n
    }
    passdb passwd-file {
        args = /etc/dovecot/passwd
    }
}

(Don't forget to create user vmail with group vmail.)

/etc/dovecot/passwd:

test@example.net:{PLAIN}yoursecretpassword

Of course all this is just a simple example (derived from an actual configuration), you can use any user backend you wish with any tools to manage it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.