UW-IMAP・Dovecotの設定

UW-IMAPを使ってpopサーバを構築します。以前はqpopperを使っていましたが、squirrelmail(WebMail)メール構築するためにimapの設定が簡単にできるのでこちらにしました。 設定は非常に簡単です。インストールして起動設定をするだけで本当にシンプルです。
RedHatやFedora Coreの2枚目にありますのでそちらを使います。RedHat9.0でしたらimap-2001a-18のパッケージになっていると思います。ないようでしたらRedHatLinux用の日本語対応パッケージ(スコットさんのページ)からダウンロードできます。(古いバージョンはありません)
RedHat Linux では UW IMAP が標準の IMAP サーバでありますが、RPMパッケージ名は imap になります。mbox 形式のスプールに対応しているので /var/spool/mail 以下にユーザ名ごとのメールスプールがある場合には利用可能ですが、Maildir 形式のスプールには使用できません。Maildir の場合には Courier-IMAP を利用します。また、メールサーバにユーザのログインアカウントを作らずにメールの受信だけを行なうようなケースにおいては Cyrus IMAP を使用して実現することができると思います。
またFedoraCore2以降になるとimapの代わりにdovecot(ドベコット?)が標準採用せれていますのでこちらの場合は下記のように設定します。
また、FedoraCore6のバージョンでは、yumなどでアップデートするとUW IMAPがアップデートされてRPMでインストールが出来るようになります。
# mount /mnt/cdrom ←cdをマウントします。
# cd /mnt/cdrom/RedHat/RPMS
# rpm -ihv imap-2001a-18.i386.rpm
警告: imap-2001a-18.i386.rpm: v3 DSA signature: NOKEY, KEY ID db42a60e
preparing・・・      ########################################### 100%
  1:imap        ########################################### 100%

# cd ←rootに戻ります
# umount /mnt/cdrom ←cdを解除します。
popとimapの起動設定をします。
# chkconfig ipop3 on
# chkconfig imap on
以上でpopサーバの設定終了。
UW IMAPの場合はxinetd(スーパーサーバ)を一応再起動しておきます。
# service xinetd restart

※ FedoraCore6の場合はxinetdが起動してませんので service xinetd start になります。起動できるように chkconfig xinetd on を実行しておきます。


FedoraCore2以降からdovecotが採用されています。
dovecotの設定FedoraCore2のCD、DVDのパッケージなどからインストールします。または、RedHatLinux用の日本語対応パッケージ(スコットさんのページ)からrpmのdovecotをダウンロードします。
適当な場所に保存してからcdコマンドで保存したカレントディレクトリへ移動します。
dovecotoをインストールします。(ここでは、保存場所を/usr/local/src)
[root@root ~]#cd /usr/local/src
[root@root ~]# rpm -ihv dovecot-0.99.11-1_fc2.i386.rpm
警告: dovecot-0.99.11-1_fc2.i386.rpm: v3 DSA signature: NOKEY, KEY ID ab14c60f
preparing・・・      ########################################### 100%
  1:dovecot      ########################################### 100%

#行はコメントになります。 翻訳文参照は、→ こちらからDovecot1.07
/etc/dovecot.conf からファイルを編集します。
[root@root ~]# vi /etc/dovecot.conf

# Protocols we want to be serving:
protocols = imap imaps pop3 pop3s ←#を取る

dovecot1.0 以前の場合
メールボックス(Maildir)を各ユーザのホームディレクトリに配置
# Default MAIL environment to use when it's not set. By leaving this empty
# dovecot tries to do some automatic detection as described in
# doc/mail-storages.txt. There's a few special variables you can use:
#
# %u - username
# %n - user part in user@domain, same as %u if there's no domain
# %d - domain part in user@domain, empty if user there's no domain
# %h - home directory
#
# You can also limit a width of string by giving the number of max. characters
# after the '%' character. For example %1u gives the first character of
# username. Some examples:
#
# maildir:/var/mail/%1u/%u/Maildir
# mbox:~/mail/:INBOX=/var/mail/%u
# mbox:/var/mail/%d/%n/:INDEX=/var/indexes/%d/%n
#
default_mail_env = maildir:~/Maildir ←#を取って追加(メールボックスをMaildir形式とする)


dovecot1.0-1 以降の場合
# Location for users' mailboxes. This is the same as the old default_mail_env
# setting. The default is empty, which means that Dovecot tries to find the
# mailboxes automatically. This won't work if the user doesn't have any mail
# yet, so you should explicitly tell Dovecot the full location.
#
# If you're using mbox, giving a path to the INBOX file (eg. /var/mail/%u)
# isn't enough. You'll also need to tell Dovecot where the other mailboxes are
# and where Dovecot can place its index files. This is called the "root mail
# directory", and it must be the first path given in the mail_location setting.
#
# There are a few special variables you can use, eg.:
#
# %u - username
# %n - user part in user@domain, same as %u if there's no domain
# %d - domain part in user@domain, empty if there's no domain
# %h - home directory
#
# See doc/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
#
# http://wiki.dovecot.org/MailLocation
#
mail_location = maildir:~/Maildir ←#を取って追加


Sendmail の特性上MTAでメールが配送されるためにMDAで配送するには向いていないので、
Sendmail で Maildir を使うにはMDAで正しく配送されるようにします。
そこで sendmail.mc ファイルの適切な位置に FEATURE(`local_procmail') を書いて上げる必要があります。
RedHat Linux、FedoraCore の標準設定ではMDAに procmail を使うようにはじめから設定されていますのでまったくいじる必要もありません。
/etc/procmailrcファイルをMaildirにすればOKです。
以下のように新しくファイルを作成します。
[root@root ~]# vi /etc/procmailrc

SHELL=/bin/bash
PATH=/usr/bin:/bin
DROPPRIVS=yes
MAILDIR=$HOME/Maildir
DEFAULT=$MAILDIR/
#LOGFILE=$HOME/procmail.log
# ログ出力先 #VERBOSE=ON # 詳細ログ出力


chrootユーザのディレクトリの場合
# ':' separated list of directories under which chrooting is allowed for mail
# processes (ie. /var/mail will allow chrooting to /var/mail/foo/bar too).
# This setting doesn't affect login_chroot or auth_chroot variables.
# WARNING: Never add directories here which local users can modify, that
# may lead to root exploit. Usually this should be done only if you don't
# allow shell access for users. See doc/configuration.txt for more information.
valid_chroot_dirs = /home ←#を取って追加(OpenSSH+Chrootを導入している場合)

Dovecot Ver 1.0からは POP3 UIDL format 変更されたのでFedoraCore5ですと
メールログ「/var/log/maillog」に以下が出力され、メーラより取得する事が出来ない。
Jun 8 21:31:38 root dovecot: POP3(linux): pop3_uidl_format setting is missing from config file
Jun 8 21:31:38 root dovecot: child 2741 (pop3) returned error 89

以下のコマンドを実施して Ver 1.0以降FedoraCore5であれば、使う POP3 の UIDL (ユニークなメール識別子)フォーマットを安全にするためpop3_uidl_format = %08Xu%08Xv の変更をします。
[root@fedora ~]# rpm -qa dovecot ←確認
dovecot-1.0-0.beta8.1.fc5
[root@root ~]# vi /etc/dovecot.conf
# POP3 UIDL format to use. You can use following variables:
#
# %v - Mailbox UIDVALIDITY
# %u - Mail UID
# %m - MD5 sum of the mailbox headers in hex (mbox only)
# %f - filename (maildir only)
#
# If you want UIDL compatibility with other POP3 servers, use:
# UW's ipop3d : %08Xv%08Xu
# Courier version 0 : %f
# Courier version 1 : %u
# Courier version 2 : %v-%u
# Cyrus (<= 2.1.3) : %u
# Cyrus (>= 2.1.4) : %v.%u
# Older Dovecots : %v.%u
#
# Note that Outlook 2003 seems to have problems with %v.%u format which was
# Dovecot's default, so if you're building a new server it would be a good
# idea to change this. %08Xu%08Xv should be pretty fail-safe.
#
# NOTE: Nowadays this is required to be set explicitly, since the old
# default was bad but it couldn't be changed without breaking existing
# installations. %08Xu%08Xv will be the new default, so use it for new
# installations.
#
#pop3_uidl_format = %08Xu%08Xv
pop3_uidl_format = %08Xu%08Xv ←# を取を外します
dovecotを起動させます。
[root@root ~]# service dovecot start
Dovecot Imap を起動中: [ OK ]
[root@root ~]#

OSの再起動を行なった時にdovecot(POPサーバー)を自動的に起動するように設定する
dovecotの起動設定をします。
[root@root ~]# chkconfig dovecot on
設定内容を確認
[root@root ~]# chkconfig --list dovecot
dovecot 0:オフ 1:オフ 2:オン 3:オン 4:オン 5:オン 6:オフ

戻る