Public Mailboxes
================

Public mailboxes are typically mailboxes that are visible to all users or to
large user groups. They are created by defining a public namespace, under which
all the shared mailboxes are. See<SharedMailboxes.Permissions.txt> for issues
related to filesystem permissions. See<Namespaces.txt> for details of how
namespaces are configured.

For example to create a public Maildir mailboxes, use:

---%<-------------------------------------------------------------------------
# When creating any namespaces, you must also have a private namespace:
namespace private {
  separator = /
  prefix =
  inbox = yes
}

namespace public {
  separator = /
  prefix = Public/
  location = maildir:/var/mail/public
  subscriptions = no  # v1.1+
}
---%<-------------------------------------------------------------------------

In the above example, you would then create Maildir mailboxes under the
/var/mail/public/ directory. For example:

---%<-------------------------------------------------------------------------
# ls -la /var/mail/public/
drwxr-s--- 1 root mail 0 2007-03-19 03:12 .
drwxrws--- 1 root mail 0 2007-03-19 03:12 .lkml
drwxrws--- 1 root mail 0 2007-03-19 03:12 .bugtraq
-rw-rw---- 1 root mail 0 2007-03-19 03:12 dovecot-shared
---%<-------------------------------------------------------------------------

Note that there are no 'cur/', 'new/' or 'tmp/' directories directly under the
'/var/mail/public/', because the Public/ namespace isn't a mailbox itself.

Maildir: Per-user \Seen flag
----------------------------

With Maildir a 'dovecot-shared' file controls if the \Seen flags are shared or
private. If the file doesn't exist, the \Seen flags are shared. If the file
exists, the \Seen flag state is stored only in the user's index files. By
making each user have their own private index files, you can make the \Seen
flag private for the users. For example:

---%<-------------------------------------------------------------------------
namespace public {
  separator = /
  prefix = Public/
  location = maildir:/var/mail/public:INDEX=~/Maildir/public
  subscriptions = no  # v1.1+
}
---%<-------------------------------------------------------------------------

Now when accessing e.g. "Public/lkml" mailbox, Dovecot keeps its index files in
'~/Maildir/public/lkml/' directory. If it ever gets deleted, the \Seen flags
are lost.

The 'dovecot-shared' file has also another purpose: Its permissions are copied
to files created under the mailbox. This was necessary with v1.1, but with v1.2
there are other ways to handle it. See<SharedMailboxes.Permissions.txt> for
more information.

If you want to change what flags are shared when 'dovecot-shared' file exists,
currently you'll have to modify the source
code:'src/lib-storage/index/maildir/maildir-storage.c' maildir_open() has
'mbox->ibox.box.private_flags_mask = MAIL_SEEN;' Change the 'MAIL_SEEN' to any
flag combination you want (or zero). See 'src/lib-mail/mail-types.h' for list
of valid flags.

Maildir: Keyword sharing
------------------------

Make sure you don't try to use per-user CONTROL directory. Otherwise
'dovecot-keywords' file doesn't get shared and keyword mapping breaks.

Other mailbox formats
---------------------

Currently you can't have any per-user flags with other mailbox formats than
Maildir.

Subscriptions
-------------

Typically you want each user to have control over their own subscriptions for
mailboxes in public namespaces. This is why with v1.1+ you should set
'subscriptions=no' to the namespace. Dovecot will then use the parent
namespace's subscriptions file. Note that this practically means you must have
a namespace with empty prefix, otherwise there is no "parent namespace".

With Dovecot v1.0 you can't set 'subscriptions=no', which makes things more
problematic. You could create per-user subscriptions by changing CONTROL
directory, but this breaks setting keywords. You could also make the
subscriptions file shared and not let any user modify it. This can be done by
removing write permissions from the directory containing the subscriptions
file.

Read-only mailboxes
-------------------

Read-only mboxes
----------------

If you have a read-only directory structure containing mbox files, you'll need
to store index files elsewhere:

---%<-------------------------------------------------------------------------
namespace public {
  prefix = Public/
  location = mbox:/var/mail/public/:INDEX=/var/indexes/public
  subscriptions = no  # v1.1+
}
---%<-------------------------------------------------------------------------

In the above example all the users would still be sharing the index files, so
you might have problems with filesystem permissions. Alternatively you could
place the index files under user's home directory.

Read-only Maildirs
------------------

If your Maildir is read-only, the control and index files still need to be
created somewhere. You can specify the path for these by appending
':CONTROL=<path>:INDEX=<path>' to mail location. The path may point to a
directory that is shared among all users, or to a per-user path. Note that if
the Maildir has any keywords, the per-user control directory breaks the
keywords since there is no 'dovecot-keywords' file.

When configuring multiple namespaces, the CONTROL/INDEX path must be different
for each namespace. Otherwise if namespaces have identically named mailboxes
their control/index directories will conflict and cause all kinds of problems.

If you put the control files to a per-user directory, you must also put the
index files to a per-user directory, otherwise you'll get errors. It is however
possible to use shared control files but per-user index files, assuming you've
set up permissions properly.

---%<-------------------------------------------------------------------------
namespace public {
  separator = /
  prefix = Public/
  location =
maildir:/var/mail/public:CONTROL=~/Maildir/public:INDEX=~/Maildir/public
  subscriptions = no  # v1.1+
}
namespace public {
  separator = /
  prefix = Team/
  location = maildir:/var/mail/team:CONTROL=~/Maildir/team:INDEX=~/Maildir/team
  subscriptions = no  # v1.1+
}
---%<-------------------------------------------------------------------------

(This file was created from the wiki on 2009-03-02 04:42)
