POPサーバ設定

Dovecotをインストール。
参考:http://pierre.vg/x/modules/pukiwiki/?Postfix%A1%DCDovecot%A4%C7%A5%E1%A1%BC%A5%EB%A5%B5%A1%BC%A5%D0%B9%BD%C3%DB%A1%CADebian%CA%D4%A1%CB

degas@debian:~$ sudo apt-get install dovecot
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています... 完了        
パッケージ dovecot はデータベースには存在しますが、利用できません。
おそらく、そのパッケージが見つからないか、もう古くなっているか、
あるいは別のソースからのみしか利用できないという状況が考えられます
しかし、以下のパッケージで置き換えられています:
  dovecot-common
E: パッケージ dovecot にはインストール候補がありません

ではちょっと変更。

degas@debian:~$ sudo apt-get install dovecot [TABキーで補完]
dovecot         dovecot-common  dovecot-imapd   dovecot-pop3d

IMAPを使うつもりはないのでPOP3を入れる。

degas@debian:~$ sudo apt-get install dovecot-pop3d 
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています... 完了        
以下の特別パッケージがインストールされます:
  dovecot-common libmysqlclient15off mysql-common
以下のパッケージが新たにインストールされます:
  dovecot-common dovecot-pop3d libmysqlclient15off mysql-common
アップグレード: 0 個、新規インストール: 4 個、削除: 0 個、保留: 0 個。
3485kB のアーカイブを取得する必要があります。
展開後に追加で 7291kB のディスク容量が消費されます。
続行しますか [Y/n]? y
取得:1 http://security.debian.org etch/updates/main mysql-common 5.0.32-7etch4 [53.8kB]
取得:2 http://security.debian.org etch/updates/main libmysqlclient15off 5.0.32-7etch4 [1791kB]
取得:3 http://security.debian.org etch/updates/main dovecot-common 1.0.rc15-2etch3 [1128kB]
取得:4 http://security.debian.org etch/updates/main dovecot-pop3d 1.0.rc15-2etch3 [512kB]
3485kB を 10s で取得しました (348kB/s)                                         
未選択パッケージ mysql-common を選択しています。
(データベースを読み込んでいます ... 現在 42282 個のファイルとディレクトリがインストールされています。)
(.../mysql-common_5.0.32-7etch4_all.deb から) mysql-common を展開しています...
未選択パッケージ libmysqlclient15off を選択しています。
(.../libmysqlclient15off_5.0.32-7etch4_i386.deb から) libmysqlclient15off を展開しています...
未選択パッケージ dovecot-common を選択しています。
(.../dovecot-common_1.0.rc15-2etch3_i386.deb から) dovecot-common を展開しています...
未選択パッケージ dovecot-pop3d を選択しています。
(.../dovecot-pop3d_1.0.rc15-2etch3_i386.deb から) dovecot-pop3d を展開しています...
mysql-common (5.0.32-7etch4) を設定しています ...
libmysqlclient15off (5.0.32-7etch4) を設定しています ...

dovecot-common (1.0.rc15-2etch3) を設定しています ...
adduser: Warning: that home directory does not belong to the user you are currently creating.
Adding user `dovecot' to group `mail' ...
終了。
Creating generic self-signed certificate: /etc/ssl/certs/dovecot.pem
(replace with hand-crafted or authorized one if needed).

dovecot-pop3d (1.0.rc15-2etch3) を設定しています ...

ではWebminを見てみる。おお、サーバ > Dovecot IMAP/POP3 Serverが使えるようになっている。

  • Networking and ProtocolsのServe mail protocolsでPOP3を選択。

さて。…あれ?動いてない。
Webminから起動させてみるといちおう動いたがエラーが出る。

アクションの開始中
コマンド /etc/init.d/dovecot start を実行中..

Starting mail server: dovecotWarning: Fixing permissions of /var/run/dovecot to be world-readable
Warning: Corrected permissions for login directory /var/run/dovecot/login
.

参考:http://forum.ubuntulinux.jp/viewtopic.php?pid=4136
postfix(3) - コンピュータはんぱもん
後者に従い、

degas@debian:~$ sudo chown dovecot /var/run/dovecot/login

とする。

degas@debian:~$ ls -l /var/run/dovecot/
合計 4
srwxrwxrwx 1 root    root       0 2008-01-11 16:59 dict-server
drwxr-x--- 2 dovecot dovecot 4096 2008-01-11 16:59 login

ついでにサーバ > Dovecot IMAP/POP3 Server > User and Login Optionsを選択。

  • Authentication methodsをAPOPに変更してみる。

その後にWebminから起動させるとやはりまたエラー。

eiji@debian:~$ ls -l /var/run/dovecot/
合計 4
srwxrwxrwx 1 root root       0 2008-01-11 17:01 dict-server
drwxr-x--- 2 root dovecot 4096 2008-01-11 17:01 login

…やはり前者の問題があるようですな。
しかも起動してないし。/var/log/mail.logを見ると

Jan 11 17:06:27 debian dovecot: Dovecot v1.0.rc15 starting up
Jan 11 17:06:28 debian dovecot: auth(default): APOP mechanism can't be supported with given passdbs
Jan 11 17:06:28 debian dovecot: Auth process died too early - shutting down
Jan 11 17:06:28 debian dovecot: child 6129 (auth) returned error 89
Jan 11 17:06:28 debian dovecot: Temporary failure in creating login processes, slowing down for now

APOPの設定がよろしくない、と。
仕方ない。切っておこう。

ちゃんと起動した。

Jan 11 17:09:59 debian dovecot: Dovecot v1.0.rc15 starting up

しかし、Eudoraからメールを取りに行くと

  • ERR Plaintext authentication disabled.

と怒られる。…ひとまずは平文での接続を可能にしましょう。
サーバ > Dovecot IMAP/POP3 Server > SSL Configurationを選択する。

  • Disallow plaintext authentication in non-SSL mode?を「デフォルト(はい)」から「いいえ」へ変更して「保存」ボタンを押し、そして「Apply Configuration」ボタンを押す。

ちなみに /etc/dovecot/dovecot.confだと

# IP or host address where to listen in for connections. It's not currently
...skipping...
#disable_plaintext_auth = yes
disable_plaintext_auth = no

のようにdisable_plaintext_authをnoにする。

…ようやく接続できるようになった。疲れた…。


しかし。
また環境変数MAILが変更されている。

degas@debian:~$ echo $MAIL
/var/mail/degas

戻されてるやん。

もう止め。
どうもdovecotはMailbox形式と相性が悪そう。
となると、qmailで使われていたMaildir形式にした方がよいのだろうか。世間一般ではdovecotIMAPサーバとして使っている方が多いようだし。

では。Maildirにするか。
Postfixの設定も変えなきゃ。
Webmin > Postfixの設定 > ローカル配信の「ユーザメールボックスファイルのホーム相対パス名」を「Maildir/」に変更して「保存して適用」ボタンを押す。
Webmin > Dovecot IMAP/POP3 Server > Mail Filesの「Mail file location」で「nbox in ~/Maildir, folders in ~/mail」をチェック。「保存」して「Apply Configuration」する。

Eudoraからメールを送ってみると、~/Maildir/newに届いている。
そしてEudoraでメールを取ってみる。よし、ちゃんと取れた。ではこれで良い。
その際の/var/log/mail.log。

Jan 11 17:38:44 debian dovecot: pop3-login: Login: user=<degas>, method=PLAIN, rip=192.168.126.2, lip=192.168.126.96
Jan 11 17:38:44 debian dovecot: POP3(degas): Disconnected: Logged out top=0/0, retr=1/722, del=0/1, size=706

で、POPしたメールは~Maildir/cur/に移った。

degas@debian:~$ ls -l Maildir/ Maildir/cur/ Maildir/new/ Maildir/tmp/
Maildir/:
合計 40
drwx------ 2 degas degas  4096 2008-01-11 17:38 cur
-rw------- 1 degas degas    57 2008-01-11 17:38 dovecot-uidlist
-rw------- 1 degas degas   156 2008-01-11 17:38 dovecot.index
-rw------- 1 degas degas 16384 2008-01-11 17:38 dovecot.index.cache
-rw------- 1 degas degas   224 2008-01-11 17:38 dovecot.index.log
drwx------ 2 degas degas  4096 2008-01-11 17:38 new
drwx------ 2 degas degas  4096 2008-01-11 17:34 tmp

Maildir/cur/:
合計 4
-rw------- 1 degas degas 687 2008-01-11 17:34 1200040477.V301I24ed94M421600.debian:2,S

Maildir/new/:
合計 0

Maildir/tmp/:
合計 0