dovecot 的官方網站在http://www.dovecot.org/,引述自官方網站:「Dovecot is anopen sourceIMAPandPOP3email server for Linux/UNIX-like systems」。
不過話說回來,如果有預算的話,把 mail 外包給 Google 是最好的,一個帳號一個月也才 150 元。
在 FreeBSD 10.0 底下開始安裝 dovenet。
root@foo:~ # pkg search dovecot
cyrus2dovecot-1.2
dovecot-1.2.17_1
dovecot-antispam-1.3_2,1
dovecot-managesieve-0.11.13_1
dovecot-pigeonhole-0.4.3
dovecot-sieve-1.2+0.1.19_1
dovecot2-2.2.13
dovecot2-antispam-plugin-20130429_7
root@foo:~ # pkg install dovecot2-2.2.13
1.xx 版就不要用了,官網已經註明這個版本已經過時 (obsolete);自從 FreeBSD 全面使用 pkg 後,真的是方便的不得了,不過在此同時,ports 是可以同時使用的,並不會衝突。
按下 Enter 後,大概一口咖啡的時間,就裝好了,接下來:
root@foo:~ # cd /usr/local/etc/dovecot
root@foo:~ # cp /usr/local/share/doc/dovecot/example-config/dovecot.conf .
root@foo:~ # cp -R /usr/local/share/doc/dovecot/example-config/conf.d/ conf.d
root@foo:~ # rm conf.d/10-ssl.conf
在 /usr/local/share/doc/dovecot/example-config/ 底下,有好幾個設定檔的範例,如果你的使用比較複雜,或許其他的設定檔範例會更適合你使用。
然後,暫時,先不用 SSL,所以目前先刪除 SSL 的設定。
不修改任何現有的設定檔,新增一個設定檔,覆蓋掉一些預設值就可以了。
root@foo:/usr/local/etc/dovecot # cat local.conf
passdb {
driver = pam
}
service auth {
user = root
}
userdb {
driver = passwd
}
ssl = no
protocols = imap pop3
mail_location = mbox:~/mail:INBOX=/var/mail/%u
login_greeting = Welcome to Foo Commpany. Dovecot ready.
disable_plaintext_auth = no
mail_privileged_group=mail
root@foo:/usr/local/etc/dovecot # cat /etc/pam.d/dovecot
# https://forums.freebsd.org/viewtopic.php?&t=41002
auth required pam_unix.so
account required pam_unix.so
最後,rc.conf 當然要加上一行「dovecot_enable="YES"」,然後就大功告成了。
root@foo:/usr/local/etc/dovecot # /usr/local/etc/rc.d/dovecot start
Starting dovecot.
root@foo:/usr/local/etc/dovecot # tail /var/log/maillog
Jun 23 00:51:45 foo dovecot: master: Dovecot v2.2.13 starting up for imap, pop3
接下來,測試 pop3 和 imap 是不是真的可以用了,首先,你必須先建立使用者,並且寄個兩封信給他。
測試 POP3。
root@foo:/usr/local/etc/dovecot # telnet localhost pop3
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK Welcome to foo.com. Dovecot ready.
USER kenchen
+OK
PASS password
+OK Logged in.
LIST
+OK 2 messages:
1 2503
2 2089
.
RETR 2
+OK 2089 octets
Return-Path:
X-Original-To: kenchen@foo.com
Delivered-To: kenchen@foo.com
Received: from mail-yk0-f170.google.com (mail-yk0-f170.google.com [209.85.160.170])
by xxx.localdomain (Postfix) with ESMTP id 49DD0B05E9
for ; Wed, 18 Jun 2014 05:50:38 +0800 (CST)
Received: by mail-yk0-f170.google.com with SMTP id q9so5696629ykb.15
for ; Tue, 17 Jun 2014 14:50:37 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;
h=mime-version:from:date:message-id:subject:to:content-type;
bh=2o91acm+mWhlDPss1H7aKB0b5xHMmFzaMBgU4AvcDpU=;
b=DVmBE7LTcysjfdSwg9bpvm1VJQmm+T6eTDDunpjVclcr3fGf/A9Q7mycZDWKGr7Giv
9RRQFPKvbYZROf997aSMq9a8D8+RXUzYAURCTEUWdhtsDHZdhB27wGqkeIMDqFwU6QGg
EU3WWxtYR8/1MUlUFigQv7kMESyCqrcw8Ygj10Rf3SKy10t+Y/x0cUnX/y+NxOOcMOF+
XccWYAC8Gq54/DkCRO072IinP5ZFstgzRiZ2AUf/F8z7Yg1On6vwITlWXaPiHP4oMetU
/XebHWADZlmolDMcPBE+MweZx7fOfP5UI7vI5t4UK67HizumeJBEC/SS6CH168FKMiGv
vakw==
X-Received: by 10.236.76.105 with SMTP id a69mr49012294yhe.8.1403041358124;
Tue, 17 Jun 2014 14:42:38 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.170.34.2 with HTTP; Tue, 17 Jun 2014 14:42:17 -0700 (PDT)
From: someuser
Date: Wed, 18 Jun 2014 05:42:17 +0800
Message-ID:
Subject: test test test
To: kenchen@foo.com
(略)
.
QUIT
+OK Logging out.
Connection closed by foreign host.
如果 POP3 沒有問題的話,IMAP 應該就不會有問題了,測試 IMAP 的方法,可以看http://www.anta.net/misc/telnet-troubleshooting/imap.shtml。