Dovecot

Procmail 和 Thunderbird:以 root 作為所有者創建的文件夾/maildir

  • April 15, 2019

我配置了一個郵件伺服器(spamassassin+procmail+sendmail+dovecot) 我希望將所有垃圾郵件重定向到我設置的垃圾郵件文件夾 /etc/procmail

DEFAULT=/var/spool/mail/$LOGNAME/new
ORGMAIL=/var/spool/mail/$LOGNAME
MAILDIR=/var/spool/mail/$LOGNAME

# deliver spam to spam folder
:0:
* ^X-Spam-Status: Yes
.Spam/

和鴿舍郵箱

inbox = yes
 #mailbox name {
   # auto=create will automatically create this mailbox.
   # auto=subscribe will both create and subscribe to the mailbox.
   #auto = no

   # Space separated list of IMAP SPECIAL-USE attributes as specified by
   # RFC 6154: \All \Archive \Drafts \Flagged \Junk \Sent \Trash
   #special_use =
 #}

 # These mailboxes are widely used and could perhaps be created automatically:
 mailbox Drafts {
   special_use = \Drafts
   auto = create
 }
 mailbox Spam {
   special_use = \Junk
   auto = create
 }
 mailbox Trash {
   special_use = \Trash
   auto = create
 }

當我發送垃圾郵件進行測試時,它不會在 Thunderbird 上自動創建文件夾,並且我看到該文件夾(存在於系統上)具有 root 權限而不是使用者權限,當然如果在另一封郵件發送後執行 chown 返回到原始權限(根!)

找到的解決方案:

mailbox Spam {
   special_use = \Junk
   auto = create
}

變成了

mailbox Spam {
   special_use = \Junk
   auto = subscribe
}

現在它可以工作了

DROPPRIVS=yes在開頭添加/etc/procmailrc

man procmailrc:

DROPPRIVS 如果設置為“yes”,procmail 將放棄它可能擁有的所有權限(suid 或 sgid)。這僅在您想保證 /etc/procmailrc 文件的下半部分代表收件人執行時才有用。

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