メールサーバー構築(その2・Dovecot(受信メールサーバー))【カゴヤ・クラウド/VPSをいじる】(未解決・いつかやる)

続いて受信メール(POP3・IMAP)サーバーDovecot(ダヴコット)のインストールを行います。

Dovecotのインストール

yumのみでいけます。

[root@v0000 ~]# yum -y install dovecot

バージョン確認もしておきます。

[root@v0000 ~]# rpm -qa | grep dovecot
dovecot-2.2.10-4.el7_0.1.x86_64

Dovecot設定

まず,dovecot.confの設定変更です。

[root@v0000 ~]# nano /etc/dovecot/dovecot.conf

# Most (but not all) settings can be overridden by different protocols and/or
# source/destination IPs by placing the settings inside sections, for example:
# protocol imap { }, local 127.0.0.1 { }, remote 10.0.0.0/8 { }

# Default values are shown for each setting, it's not required to uncomment
# those. These are exceptions to this though: No sections (e.g. namespace {})
# or plugin settings are added by default, they're listed only as examples.
# Paths are also just examples with the real defaults being based on configure
# options. The paths listed here are for configure --prefix=/usr
# --sysconfdir=/etc --localstatedir=/var

# Protocols we want to be serving.
protocols = imap pop3 pop3s imaps ← コメントアウト&追記

続いて10-mail.confの設定変更です。

[root@v0000 ~]# nano /etc/dovecot/conf.d/10-mail.conf

##
## Mailbox locations and namespaces
##

# Location for users' mailboxes. The default is empty, which means that Dovecot
# tries to find the mailboxes automatically. This won't work if the user
# doesn't yet have any mail, 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
# kept. 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/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 =
mail_location = maildir:~/Maildir ← 追加(メールボックス形式をMaildir形式とする)


# ':' 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, mail_chroot or auth chroot
# settings. If this setting is empty, "/./" in home dirs are ignored.
# 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. <doc/wiki/Chrooting.txt>
valid_chroot_dirs = /home ←コメントアウトしてchrootユーザーのディレクトリ設定

10-auth.confも。

[root@v0000 ~]# nano /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.
# See also ssl=required setting.
disable_plaintext_auth = no ← コメントアウトして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 = plain login ← loginを追加

SSL接続したいときは追加の設定が必要です。

それに関してはまた今度。

とりあえずSSL要求させないようにします。

[root@v0000 ~]# nano /etc/dovecot/conf.d/10-ssl.conf

##
## SSL settings
##

# SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>
# disable plain pop3 and imap, allowed are only pop3+TLS, pop3s, imap+TLS and i$
# plain imap and pop3 are still allowed for local connections
ssl = no ← requiredからnoに変更

もう一つ,20-pop3.confも変更です。

[root@v0000 ~]# nano /etc/dovecot/conf.d/20-pop3.conf

# 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.
#
#pop3_uidl_format = %08Xu%08Xv

から

pop3_uidl_format = %u

Dovecot起動

Postfix再起動→自動起動設定を行います。

今回もsystemctlがうまくいくのか?

[root@v0000 ~]# systemctl start dovecot ← Dovecot起動
[root@v0000 ~]# systemctl enable dovecot ← Dovecot自動起動設定
ln -s '/usr/lib/systemd/system/dovecot.service' '/etc/systemd/system/multi-user.target.wants/dovecot.service'

ん?何かおかしい。dovecot.serviceでいけばいいのか?

やってみました。(やらなくて良さげのよう)

[root@v0000 ~]# systemctl start dovecot.service ← Dovecot起動
[root@v0000 ~]# systemctl enable dovecot.service ← Dovecot自動起動設定

大丈夫かどうか確認。

[root@v2359 ~]# systemctl is-enabled dovecot
enabled

大丈夫でしょう。多分。

POP3は110番ポート,IMAPは143番ポートを開けておきます。

#110番ポート(POP3)オープン
[root@v0000 ~]# iptables -A INPUT -p tcp --dport 110 -j ACCEPT
[root@v0000 ~]# iptables -A OUTPUT -p tcp --dport 110 -j ACCEPT
#143番ポート(IMAP)オープン
[root@v0000 ~]# iptables -A INPUT -p tcp --dport 143 -j ACCEPT
[root@v0000 ~]# iptables -A OUTPUT -p tcp --dport 143 -j ACCEPT

#iptablesの設定保存と再起動を忘れずに(3回目)
[root@v0000 ~]# iptables-save > /etc/sysconfig/iptables
[root@v0000 ~]# systemctl restart iptables.service

ポート開放確認はここでやるとよいです。

ポートチェック【外部からポート開放確認】
サーバー管理者用の支援ページです。管理中のサーバーが外部からPortアクセス可能かをリアルタイムにチェック確認できます。

以上です。

コメント

Secured By miniOrange