2015年10月14日 星期三

Roundcube+Dovecot UID MOVE: Mailbox doesn't exist: Trash 解決辦法

Roundcube預設不會直接產生使用者帳號下需要的各個資料夾,當使用者有需求時才會自產生!例如第一次登入時只會有”收件夾”和“寄件備份”兩個資料夾,當使用者刪除信件時,系統會自產生“垃圾桶”這個資料夾,並將刪除的信件放入其中!但某些系統安裝後卻無法自己產生相對應需求的資料夾!便會出現“伺服器錯誤:UID MOVE: Mailbox doesn't exist: Trash”這樣的錯誤訊息!
解決的辦法有兩個:
1.讓Roundcube直接建立預設的資料夾
編輯Roundcube目錄下config資料夾下的config.inc.php檔案,在最下方加入
$config['create_default_folders'] = True;
存檔後使用者再重新登入roundcube即可!

2.編/etc/dovecot/conf.d/20-imap.conf如下,讓dovecot支援自動建立目錄的功能:
mail_plugins = $mail_plugins autocreate

20-imap.conf檔案的最後加上以下內容:
plugin {
autocreate = Trash
autocreate2 = Junk
autocreate3 = Drafts
autocreate4 = Sent
autosubscribe = Trash
autosubscribe2 = Junk
autosubscribe3 = Drafts
autosubscribe4 = Sent
}

存檔後重新啟動dovecot即可!
PS:若dovecot是2.2以上版本,以上設定會導致/var/log/mail.log下出現:
Warning: autocreate plugin is deprecated, use mailbox { auto } setting
這樣的警告訊息!這個警告訊息不影響dovecot的正常運作!
依照Dovecot網頁文件的說法(http://wiki2.dovecot.org/MailboxSettings),dovecot 2.1之後的版本在mail_plugins = 後方不需要autocreate
,所有的autocreate = autosubscribe =  需要移除,並加入下列內容:
namespace inbox { 
#prefix = INBOX. # the namespace prefix isn't added again to the mailbox names. 
# ... 
mailbox Trash { 
auto = no 
special_use = \Trash 
 } 
mailbox Drafts { 
auto = no 
special_use = \Drafts 
 } 
mailbox Sent { 
auto = subscribe # autocreate and autosubscribe the Sent mailbox 
special_use = \Sent 
 } 
mailbox "Sent Messages" { 
auto = no 
special_use = \Sent
 } 
mailbox Spam { 
auto = create # autocreate Spam, but don't auto subscribe 
special_use = \Junk 
 } 
mailbox virtual/All {# if you have a virtual "All messages" mailbox 
auto = no 
special_use = \All 
 } 
}
所以修改完的內容應該如下:
mail_plugins = $mail_plugins 
mailbox_list_index=yes
namespace inbox { 
#prefix = INBOX. # the namespace prefix isn't added again to the mailbox names. 
# ... 
mailbox Trash { 
auto = no 
special_use = \Trash 
 } 
mailbox Drafts { 
auto = no 
special_use = \Drafts 
 } 
mailbox Sent { 
auto = subscribe # autocreate and autosubscribe the Sent mailbox 
special_use = \Sent 
 } 
mailbox "Sent Messages" { 
auto = no 
special_use = \Sent
 } 
mailbox Spam { 
auto = create # autocreate Spam, but don't auto subscribe 
special_use = \Junk 
 } 
mailbox virtual/All {# if you have a virtual "All messages" mailbox 
auto = no 
special_use = \All 
 } 
}
存檔後重新啟動dovecot即可讓dovecot支援自動產生資料夾的功能!但這個做法在目前的roundcube(1.1.4)上並沒有生效!所以建議使用第一個方式來根本解決!