・dovecot の用途
- LMTPサーバ (メール受信)
- Sieve(メールフィルタリング/メール転送)
- POP3/IMPA4サーバ (メール参照)
- ManageSieveサーバ
・dovecotをインストール
#-- 変数に必要な値を代入
DOMAIN=masdon.life
LDAP_SERVER=127.0.0.1
#-- dovecot 2.3系の repository を登録
cat <<_EOL_> /etc/yum.repos.d/dovecot.repo
[dovecot-2.3-latest]
name=Dovecot 2.3 CentOS $releasever - \$basearch
baseurl=http://repo.dovecot.org/ce-2.3-latest/centos/\$releasever/RPMS/\$basearch
gpgkey=https://repo.dovecot.org/DOVECOT-REPO-GPG
gpgcheck=1
enabled=1
_EOL_
#-- dovecot のインストールと設定
yum install -y dovecot dovecot-pigeonhole
yum install -y openldap-devel expat-devel bzip2-devel zlib-devel
#- dovecot の設定
cat <<_EOL_> /etc/dovecot/local.conf
postmaster_address = postmater@${DOMAIN}
auth_mechanisms = plain login
deliver_log_format = from=%{from_envelope}, to=%{to_envelope}, size=%p, msgid=%m, delivery_time=%{delivery_time}, session_time=%{session_time}, %\$
disable_plaintext_auth = no
first_valid_uid = 97
mail_location = maildir:/var/dovecot/%Ld/%Ln
mail_plugins = \$mail_plugins zlib
plugin {
sieve = /var/dovecot/%Ld/%Ln/dovecot.sieve
sieve_extensions = +notify +imapflags +editheader +vacation-seconds
sieve_max_actions = 32
sieve_max_redirects = 10
sieve_redirect_envelope_from = recipient
sieve_vacation_min_period = 1h
sieve_vacation_default_period = 7d
sieve_vacation_max_period = 60d
zlib_save = bz2
zlib_save_level = 5
}
protocols = imap pop3 lmtp sieve
service imap-login {
inet_listener imap {
address = 127.0.0.1
}
}
service lmtp {
inet_listener lmtp {
address = 127.0.0.1
port = 24
}
}
service pop3-login {
inet_listener pop3 {
address = 127.0.0.1
}
}
service managesieve-login {
inet_listener sieve {
address = 127.0.0.1
}
}
protocol lmtp {
mail_plugins = \$mail_plugins sieve
}
protocol imap {
mail_max_userip_connections = 20
}
ssl = no
ssl_cert =
ssl_key =
lda_mailbox_autocreate = yes
lmtp_save_to_detail_mailbox = yes
_EOL_
#- dovecot の認証設定
cp -p /etc/dovecot/conf.d/10-auth.conf{,.org}
cp -p /etc/dovecot/conf.d/auth-static.conf.ext{,.org}
sed -i 's/auth-system.conf.ext/auth-static.conf.ext/' /etc/dovecot/conf.d/10-auth.conf
cat <<_EOL_>/etc/dovecot/conf.d/auth-static.conf.ext
passdb {
driver = static
args = nopassword=y
}
# userdb {
# driver = static
# args = uid=dovecot gid=dovecot home=/var/dovecot/%Ld/%Ln allow_all_users=yes
# }
userdb {
driver = ldap
args = /etc/dovecot/dovecot-ldap.conf.ext
}
_EOL_
#- doveadm コマンドで ldap を参照する為の設定
cat <<_EOL_>/etc/dovecot/dovecot-ldap.conf.ext
hosts = ${LDAP_SERVER}
auth_bind = yes
base = ""
pass_attrs=mailRoutingAddress=User,userPassword=password
pass_filter = (&(objectClass=inetLocalMailRecipient)(mailRoutingAddress=%u))
iterate_attrs = mailRoutingAddress=user
iterate_filter = (&(objectClass=inetLocalMailRecipient)(mailRoutingAddress=*))
user_filter = (&(objectClass=inetLocalMailRecipient)(mailRoutingAddress=%u))
user_attrs = \
=uid=dovecot, \
=gid=dovecot, \
=mail=maildir:/var/dovecot/%Ld/%Ln, \
=home=/var/dovecot/%Ld/%Ln, \
=acl_groups=%{ldap:publicMailboxGroup}, \
=quota_rule=*:bytes=%{ldap:mailQuotaBytes}, \
=quota_rule2=*:messages=%{ldap:mailQuotaMessages}
_EOL_
#-- acl_group, quota_rule, quota_rule2 については 別途必要な schema を定義する必要がある。acl_group は gr1,gr2 のようにカンマ区切りで値を設定する
#- mbox 用ディレクトリの作成
mkdir /var/dovecot
chown dovecot. /var/dovecot
#-- dovecot の起動
systemctl enable dovecot
systemctl start dovecot