1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
|
Namespaces
==========
Dovecot supports fully configurable namespaces. Their original and primary
purpose is to provide Namespace IMAP extension (RFC 2342
[http://www.faqs.org/rfcs/rfc2342.html]) support, which allows giving IMAP
clients hints about where to locate mailboxes and whether they're private,
shared or public. Unfortunately most IMAP clients don't support this extension.
Dovecot namespaces can be used for several other purposes too:
* Changing the hierarchy separator
* Providing backwards compatibility when switching from another IMAP server
* Provides support for <public> [SharedMailboxes.Public.txt] and <shared>
[SharedMailboxes.Shared.txt] mailboxes
* Allows having mails in multiple different locations with possibly different
formats
Configuration
-------------
In v2.1+ there's a default inbox namespace added in '10-mail.conf'. If the
configuration doesn't explicitly specify a namespace (as was in v2.0 and older)
a default namespace is created automatically.
The section name in namespaces (e.g. 'namespace sectionname { .. } ' is used
only internally within configuration. It's not required at all, but it allows
you to update an existing namespace (like how '15-mailboxes.conf' does) or have
userdb override namespace settings for specific users
('namespace/sectionname/prefix=foo/').
Namespace types
---------------
There are 3 types of namespaces:
* private: Typically contains only user's own private mailboxes.
* shared: Contains other users' <shared mailboxes>
[SharedMailboxes.Shared.txt].
* public: Contains <public mailboxes> [SharedMailboxes.Public.txt].
Hierarchy separators
--------------------
Hierarchy separator specifies the character that is used to separate a parent
mailbox from its child mailbox. For example if you have a mailbox "foo" with a
child mailbox "bar", the full path to the child mailbox would be "foo/bar" if
the separator was '/'. With a separator '.' it would be "foo.bar".
IMAP clients, Sieve scripts and many parts of Dovecot configuration use the
configured separator when referring to mailboxes. This means that if you change
the separator, you may break things.
However, changing the separator doesn't change the on-disk "layout separator".
For example:
+-----------------------------+--------+-----+----------+---------------------+
| mail_location | Layout | NS | Mailbox | Directory |
| | sep | sep | name | |
+-----------------------------+--------+-----+----------+---------------------+
| maildir:~/Maildir | . | . | foo.bar | ~/Maildir/.foo.bar/ |
+-----------------------------+--------+-----+----------+---------------------+
| maildir:~/Maildir | . | / | foo/bar | ~/Maildir/.foo.bar/ |
+-----------------------------+--------+-----+----------+---------------------+
| maildir:~/Maildir:LAYOUT=fs | / | . | foo.bar | ~/Maildir/foo/bar/ |
+-----------------------------+--------+-----+----------+---------------------+
| maildir:~/Maildir:LAYOUT=fs | / | / | foo/bar | ~/Maildir/foo/bar/ |
+-----------------------------+--------+-----+----------+---------------------+
Note how the "namespace separator" changes only the "Mailbox name", but doesn't
change the directory where the mails are stored. The "layout separator" can
only be changed by changing the LAYOUT, which also affects the entire directory
structure.
The layout separator also restricts the mailbox names. For example if the
layout separator is '.', you can't just set separator to '/' and create a
mailbox named "foo.bar". If you need to do this, you can use <listescape>
[Plugins.Listescape.txt] plugin to add escape the mailbox names as necessary.
A commonly used separator is '/'. It probably causes the least amount of
trouble with different IMAP clients.'^' separator is troublesome with
Thunderbird.When '\' should be used it must be quoted, so one sets separator =
"\\"
You should use the same hierarchy separator for all namespaces. All list=yes
namespaces must use the same separator, but if you find it necessary (e.g. for
backwards compatibility namespaces) you may use different separators for
list=no namespaces.
Namespace settings
------------------
* type: See the "Namespace types" section above
* separator: See the "Hierarchy separators" section above
* prefix: The namespace prefix how it's visible in the NAMESPACE reply (if
hidden=no) and mailbox list (if list=yes).
* location: <Mailbox location> [MailLocation.txt]. The default is to use
'mail_location' setting.
* inbox: "yes", if this namespace contains the user's INBOX. There is only one
INBOX, so only one namespace can have inbox=yes.
* hidden: "yes", if this namespace shouldn't be listed in NAMESPACE reply.
* list: "yes" (default), if this namespace and its mailboxes should be listed
by LIST command when the namespace prefix isn't explicitly specified as a
parameter. "children" means the namespace prefix list listed only if it has
child mailboxes.
* subscriptions: "yes" (default) if this namespace should handle its own
subscriptions. If "no", then the first parent namespace with
subscriptions=yes will handle it. For example if it's "no" for a namespace
with prefix=foo/bar/, Dovecot first sees if there's a prefix=foo/ namespace
with subscriptions=yes and then a namespace with an empty prefix. If neither
is found, an error is given.
* ignore_on_failure: Normally Dovecot fails if it can't successfully create a
namespace. Set this to "yes" to continue even if the namespace creation
fails (e.g. public namespace points to inaccessible location).
* disabled: Set to "yes" to quickly disable this namespace. Especially useful
when returned by a userdb lookup to give per-user namespaces.
* alias_for: If multiple namespaces point to the same location, they should be
marked as aliases against one primary namespace. This avoids duplicating
work for some commands (listing the same mailbox multiple times). The value
for alias_for is the primary namespace's prefix. For example if the primary
namespace has empty prefix, set 'alias_for=' for the alias namespace. Or if
primary has 'prefix=INBOX/', use 'alias_for=INBOX/'.
* mailbox { .. } settings can be used to autocreate/autosubscribe mailboxes
and set their SPECIAL-USE flags.
Shared Mailboxes
----------------
See <SharedMailboxes.txt>.
Examples
--------
Mixed mbox and Maildir
----------------------
If you have your INBOX as mbox in '/var/mail/username' and the rest of the
mailboxes in Maildir format under '~/Maildir', you can do this by creating two
namespaces:
---%<-------------------------------------------------------------------------
namespace {
separator = /
prefix = "#mbox/"
location = mbox:~/mail:INBOX=/var/mail/%u
inbox = yes
hidden = yes
list = no
}
namespace {
separator = /
prefix =
location = maildir:~/Maildir
}
---%<-------------------------------------------------------------------------
Without the 'list = no' setting in the first namespace, clients would see the
"#mbox" namespace as a non-selectable mailbox named "#mbox" but with child
mailboxes (the mbox files in the '~/mail' directory), ie. like a directory. So
specifically with 'inbox = yes', having 'list = no' is often desirable.
Backwards Compatibility: UW-IMAP
--------------------------------
When switching from UW-IMAP and you don't want to give users full access to
filesystem, you can create hidden namespaces which allow users to access their
mails using their existing namespace settings in clients.
---%<-------------------------------------------------------------------------
# default namespace
namespace inbox {
separator = /
prefix =
inbox = yes
}
# for backwards compatibility:
namespace compat1 {
separator = /
prefix = mail/
hidden = yes
list = no
alias_for =
}
namespace compat2 {
separator = /
prefix = ~/mail/
hidden = yes
list = no
alias_for =
}
namespace compat3 {
separator = /
prefix = ~%u/mail/
hidden = yes
list = no
alias_for =
}
---%<-------------------------------------------------------------------------
Backwards Compatibility: Courier IMAP
-------------------------------------
*Recommended:* You can continue using the same INBOX. namespace as Courier:
---%<-------------------------------------------------------------------------
namespace inbox {
separator = .
prefix = INBOX.
inbox = yes
}
---%<-------------------------------------------------------------------------
*Alternatively:* Create the INBOX. as a compatibility name, so old clients can
continue using it while new clients will use the empty prefix namespace:
---%<-------------------------------------------------------------------------
namespace inbox {
separator = /
prefix =
inbox = yes
}
namespace compat {
separator = .
prefix = INBOX.
inbox = no
hidden = yes
list = no
alias_for =
}
---%<-------------------------------------------------------------------------
The "separator=/" allows the INBOX to have child mailboxes. Otherwise with
"separator=." it wouldn't be possible to know if "INBOX.foo" means INBOX's
"foo" child or the root "foo" mailbox in "INBOX." compatibility namespace. With
"separator=/" the difference is clear with "INBOX/foo" vs. "INBOX.foo".
The alternative configuration is not recommended, as it may introduce there
problems:
* Although clients may do LIST INBOX.*, they may still do LSUB *, resulting in
mixed results.
* If clients used empty namespace with Courier, they now see the mailboxes
with different names, resulting in redownloading of all mails (except
INBOX).
* Some clients may have random errors auto-detecting the proper default
folders (Sent, Drafts etc) if the client settings refer to old paths while
the server lists new paths.
Per-user Namespace Location From SQL
------------------------------------
You need to give the namespace a name, for example "docs" below:
---%<-------------------------------------------------------------------------
namespace docs {
type = public
separator = /
prefix = Public/
}
---%<-------------------------------------------------------------------------
Then you have an SQL table like:
---%<-------------------------------------------------------------------------
CREATE TABLE Namespaces (
..
Location varchar(255) NOT NULL,
..
)
---%<-------------------------------------------------------------------------
Now if you want to set the namespace location from the Namespaces table, use
something like:
---%<-------------------------------------------------------------------------
user_query = SELECT Location as 'namespace/docs/location' FROM Namespaces WHERE
..
---%<-------------------------------------------------------------------------
(This file was created from the wiki on 2013-11-24 04:42)
|