LoginSignup
1
3

More than 5 years have passed since last update.

メールサーバを構築してみる - CentOS

Last updated at Posted at 2018-12-07

1.PostfixとSMTP-AUTH

メール送信にパスワード認証を設け事で認証された場合のみメールの送信を許可します。

cyrus-sasl をインストールする。

yum install -y cyrus-sasl

起動、自動設定。

systemctl start saslauthd
systemctl enable saslauthd

smtpd.conf を編集する。

vim /etc/sasl2/smtpd.conf

pwcheck_method: auxprop にします。
auxprop SASL独自のパスワードデータベースsasldbを用意して認証に利用する方法

image.png

postfix をインストールする。

yum install -y postfix

main.cf を編集する。

vim /etc/postfix/main.cf

message_size_limit = 5242880
受け取れるメールのサイズを5MBにする
image.png

inet_interfaces = all
all のメールを受け取れるようにする
image.png

myhostname = mail.ドメイン
メールサーバーのホスト名を設定する
image.png

mydomain = ドメイン
ドメインを設定する。
image.png

myorigin = $mydomain
ローカルで配送依頼されたメールの送信元アドレスに付加するドメイン名を設定する
image.png

mydestination = $myhostname localhost.$mydomain localhost $mydomain
ローカルに配送するドメインを指定する。
image.png

home_mailbox = Maildir/
メールボックスファイルのユーザーのホームディレクトリからの相対パス名を指定。
image.png

smtpd_sasl_auth_enable
smtpd_sasl を有効にする。
permit_mynetworks 「mynetwork」で指定したアドレスの許可。
permit_sasl_authenticated SASL認証が通れば許可。
reject_unauth_destination 自分宛もしくは自分から送信されたものなら許可。
image.png

postfix を起動、自動設定する
systemctl restart postfix
systemctl enable postfix

2.dovecot

dovecot をインストールする。

yum install dovecot`

10-mail.conf を編集する。

vim /etc/dovecot/conf.d/10-mail.conf

mail_location = maildir:~/Maildir
メールボックス形式を追加する。
image.png

10-auth.conf を編集する。

vim /etc/dovecot/conf.d/10-auth.conf

disable_plaintext_auth = no
プレインテキスト認証を追加する。
image.png

10-ssl.conf を編集する。

vim /etc/dovecot/conf.d/10-ssl.conf

SSL接続を無効化する。
ssl = no
image.png

dovecotの起動自動設定

systemctl start dovecot
systemctl enable dovecot

3.メールユーザーの追加

adminユーザを追加する。

useradd -s /sbin/nologin admin

パスワードを設定する。

passwd admin

Authユーザーを設定する。

echo "[パスワード]" | saslpasswd2 -p -u ドメイン -c admin

ユーザーの登録を確認する。

sasldblistusers2

権限変更する。

chgrp postfix /etc/sasldb2
1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3