Dovecot 架設

  1. 安裝 dovecot 套件
    [root@mail1 ~]# yum install dovecot
    

  2. 編輯設定檔:選擇使用的協定
    [root@mail1 ~]# vim /etc/dovecot/dovecot.conf 
    # Protocols we want to be serving.
    protocols = imap pop3 lmtp
    

  3. 編輯郵件設定檔:設定郵件位置
    [root@mail1 ~]# vim /etc/dovecot/conf.d/10-mail.conf 
    
    ## 設定收信位置,若沒設定或設定錯誤,系統記錄檔會出現錯誤訊息
    ## Initialization failed: mail_location not set and autodetection failed: 
    ## Mail storage autodetection failed with home=/home/....
    mail_location = mbox:~/Mail:INBOX=/var/spool/mail/%u
    

  4. 編輯郵件設定檔:設定郵件位置寫入權限
    [root@mail1 ~]# vim /etc/dovecot/conf.d/10-mail.conf 
    
    ## 當用戶第一次使用,dovecot 會在 INBOX 位置產生一個用戶郵件檔
    ## 若沒設定 mail 權限群組,系統記錄檔會出現錯誤訊息
    ## euid is not dir owner dovecot
    ## 表示該用戶沒有權限寫入 INBOX:/var/spool/mail
    ## 查看目錄 /var/spool/mail 其他人並沒有寫入的權限,
    ## 有人會直接把該目錄權限改成 777,這不是解決問題的方法
    [root@mail1 ~]# ll -d /var/spool/mail
    drwxrwsr-x. 5 root mail 32768 Aug  7 10:03 /var/spool/mail
    
    ## 正確解法
    # Group to enable temporarily for privileged operations. Currently this is
    # used only with INBOX when either its initial creation or dotlocking fails.
    # Typically this is set to "mail" to give access to /var/spool/mail.
    mail_privileged_group = mail
    

  5. 啟動 dovecot 服務
    [root@kvm8 ~]# /etc/init.d/dovecot restart
    

  6. 設定開機啟動 dovecot 服務
    [root@kvm8 ~]# chkconfig dovecot on