POP・IMAPのMaildirへの対応

最終更新日:2013年9月14日

PostfixはSMTP機能しか持っていないため、そのままではメールクライアントソフトによってメールを読むことができません。また、Postfixでメール格納方式をMaildir方式とした場合、POPサーバやIMAPサーもMaildirに対応したものに変更する必要があります。(mailbox形式のままでPosffixを使うのあれば以下の作業は不要です)
幸い、Linux には dovecot という優れたIMAP/POP3サーバソフトが存在します。以下では、POPサーバ・IMAPとして dovecotを利用することとして説明を行います。

1.dovecot のインストール

dovecot のインストールは以下のように行います。
Debian・Ubuntu Redhat・CentOS・SL-Linux
$ sudo apt-get install dovecot-common dovecot-imapd dovecot-pop3d
# yum install dovecot
dovecot のインストールが完了すると、関連するファイルが以下に作成されます。 なお以下は、dovecot のバージョンが 2.0 以上を想定しています。
設定内容 Debian・Ubuntu  Redhat・CentOS・SL-Linux
dovecot の設定ファイル  /etc/dovecot/dovecot.conf  /etc/dovecot/dovecot.conf
dovecot のコンフィグファイル  /etc/dovecot/conf.d/*  /etc/dovecot/conf.d/*

2.dovecot の設定

dovecot でPOPおよびIMAPを利用できるようにするための設定を行っていきます。

2-1. サポートするサービスを指定する。

IMAPとPOP3をサポートするように指定します。
/etc/dovecot/dovecot.conf
::
::
# Protocols we want to be serving.
protocols = imap pop3
::
::


2-2. 動作に関する基本設定を行う。

/etc/dovecot/conf.d/10-master.conf
::
::
# Internal user is used by unprivileged processes. It should be separate from
# login user, so that login processes can't disturb other processes.
#default_internal_user = dovecot

service imap-login {
inet_listener imap {
port = 143
}
inet_listener imaps {
# port = 993
# ssl = yes
}
::
::
}
::
::
service pop3-login {
inet_listener pop3 {
port = 110
}
inet_listener pop3s {
# port = 995
# ssl = yes
}
}
::
::


2-3. メールデータの保存形式として Maildir を指定する。

/etc/dovecot/conf.d/10-mail.conf
::
::
# See doc/wiki/Variables.txt for full list. Some examples:
#
# mail_location = maildir:~/Maildir
# mail_location = mbox:~/mail:INBOX=/var/mail/%u
# mail_location = mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%n
#
# <doc/wiki/MailLocation.txt>
#
mail_location = maildir:~/Maildir

::
::


2-4. プレーンテキストでの認証を有効にする。

dovecot 2.0以上ではインストール直後はプレーンテキストによるユーザ認証は無効になっており、必ずTLS(SSL)を使った接続での認証を受け付けるようになっています。 しかし、同一組織内のユーザ向けである場合などは、従来通りのプレーンテキストの認証を有効にする事で、クライアントの設定における互換性を保てることでしょう。
プレーンテキストでの認証の無効を回避するには、以下のファイルを編集します。
/etc/dovecot/conf.d/10-auth.conf
##
## Authentication processes
##

# Disable LOGIN command and all other plaintext authentications unless
# SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
# matches the local IP (ie. you're connecting from the same computer), the
# connection is considered secure and plaintext authentication is allowed.
disable_plaintext_auth = no
::
::
# Space separated list of wanted authentication mechanisms:
# plain login digest-md5 cram-md5 ntlm rpa apop anonymous gssapi otp skey
# gss-spnego
# NOTE: See also disable_plaintext_auth setting.
auth_mechanisms = login plain
::
::


2-5. ログイン失敗時の説明を返す。

/etc/dovecot/conf.d/10-logging.conf
::
::
##
## Logging verbosity and debugging.
##

# Log unsuccessful authentication attempts and the reasons why they failed.
auth_verbose = yes
::
::


以上で設定は完了です、以下のコマンドで dovecot をリスタートさせます。
Debian・Ubuntu Redhat・CentOS・SL-Linux
$ sudo /etc/init.d/dovecot restart
# /etc/init.d/dovecot restart


Home

Mailwebmaster@robata.org

Copyright© 1998-2003 ROBATA.ORG