大网数据广告活动
服务器运维问答

How do I create separate mailbox configurations per virtual user with Dovecot?

· 52CE 我爱测

Let's say I have two virtual users: [email omitted] and [email omitted] . I want the mailboxes for bugs to be configured like this...: mailbox Sent { special_use = \Sent } mailbox Drafts { special_use = \Drafts } mailbox "Priorit…

问题原文

原帖链接 · The Tablet · CC BY-SA 4.0

Let's say I have two virtual users: [email omitted] and [email omitted].

I want the mailboxes for bugs to be configured like this...:

mailbox Sent {
  special_use = \Sent
}
mailbox Drafts {
  special_use = \Drafts
}
mailbox "Priority 1" {
  auto = subscribe
}
mailbox "Priority 2" {
  auto = subscribe
}
mailbox "Priority 3" {
  auto = subscribe
}
mailbox Unreplied {
  auto = subscribe
}
mailbox Resolved {
  auto = subscribe
}

...but have the mailboxes for admin have some different folders configured:

mailbox Sent {
  special_use = \Sent
}
mailbox Drafts {
  special_use = \Drafts
}
mailbox System {
  auto = subscribe
}
mailbox DMARC {
  auto = subscribe
}
mailbox Archives {
  auto = create
  special_use = \Archive
}
mailbox Trash {
  special_use = \Trash
}
mailbox Spam {
  auto = create
  special_use = \Junk
}

I don't want the folders for the bugs email to be copied over to the admin email, and vice versa.

What I've tried is using namespaces and then setting each virtual user's inbox namespace name via my passwd file, like this:

admin:<password>::::::userdb_mail=maildir:/home/mail/admin NAMESPACE=primary userdb_namespace/primary/inbox=yes userdb_namespace/primary/list=yes userdb_namespace/primary/prefix=primary/

bugs:<password>::::::userdb_mail=maildir:/home/mail/bugs NAMESPACE=bugs userdb_namespace/bugs/inbox=yes userdb_namespace/bugs/list=yes userdb_namespace/bugs/prefix=bugs/

but Dovecot's logs say:

namespace configuration error: Duplicate namespace prefix: "" in=0 out=408 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0

My full 15-mailboxes.conf:

namespace bugs {
  list = no
  type = private
  mailbox Sent {
    special_use = \Sent
  }
  mailbox Drafts {
    special_use = \Drafts
  }
  mailbox "Priority 1" {
    auto = subscribe
  }
  mailbox "Priority 2" {
    auto = subscribe
  }
  mailbox "Priority 3" {
    auto = subscribe
  }
  mailbox Unreplied {
    auto = subscribe
  }
  mailbox Resolved {
    auto = subscribe
  }
}
namespace primary {
  list = no
  type = private
  mailbox Sent {
    special_use = \Sent
  }
  mailbox Drafts {
    special_use = \Drafts
  }
  mailbox System {
    auto = subscribe
  }
  mailbox DMARC {
    auto = subscribe
  }
  mailbox Archives {
    auto = create
    special_use = \Archive
  }
  mailbox Trash {
    special_use = \Trash
  }
  mailbox Spam {
    auto = create
    special_use = \Junk
  }
}

已采纳解答

原帖链接 · anx · CC BY-SA 4.0

Disable & move duplicate prefixes out of the way, then revert these changes from userdb.

While you cannot have two namespaces defined with the same prefix - you do not have to define them that way if you are overriding via userdb anyway.

# in global configuration
namespace primary {
  disabled = yes
  prefix = /disable-namespace
  ...
}

# in userdb: newlines for readability
userdb_mail=maildir:/home/mail/admin
userdb_namespace=primary
userdb_namespace/primary/disabled=no
userdb_namespace/primary/prefix=
userdb_namespace/primary/inbox=yes

Careful with list=no, it does not prevent access. It merely removes the folders from the LIST output, the folder is still there (and thus precludes a second one with matching prefix!)

It is still possible to list the namespace’s folders by explicitly asking for them.

Note: That NAMESPACE=primary in your question looks out of place, why is that in the userdb (but not prefixed userdb_)?

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-06-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。