Email

如何使用 Dovecot 為每個虛擬使用者創建單獨的郵箱配置?

  • June 29, 2021

假設我有兩個虛擬使用者:bugs@domain.tldadmin@domain.tld.

我希望郵箱bugs配置如下…:

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
}

…但是郵箱admin配置了一些不同的文件夾:

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
}

希望將電子郵件的文件夾bugs複製到admin電子郵件中,反之亦然。

我嘗試的是使用命名空間,然後通過我的 passwd 文件設置每個虛擬使用者的收件箱命名空間名稱,如下所示:

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/

但 Dovecot 的日誌說:

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

我的完整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
 }
}

禁用並移開重複的前綴,然後將這些更改從userdb.

雖然您不能使用相同的前綴定義兩個命名空間 - 如果您要覆蓋via ,則不必以這種方式定義它們。userdb

# 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

小心list=no,它不會阻止訪問。它只是從LIST輸出中刪除文件夾,文件夾仍然存在(因此排除了第二個具有匹配前綴的文件夾!)

仍然可以通過顯式詢問來列出命名空間的文件夾。

注意:NAMESPACE=primary在您的問題中看起來不合適,為什麼在 userdb 中(但沒有前綴 userdb_)?

引用自:https://serverfault.com/questions/1068014