アフォでも出来る

アフォでも出来るように記録します(IT系)

OCIでメールサーバー構築ーその6 メールサーバーインストール

遂に本丸です。

OCIのCentOS7ではPostfixがデフォルトでインストールされているので設定していきます。

Postfix設定

sudo vi /etc/postfix/main.cf

 

77行目あたり。コメントアウトされている同種の記述の下に追記。

myhostname = mail.testtest.pgw.jp

84行目あたり。コメントアウトされている同種の記述の下に追記。

mydomain = testtest.pgw.jp

100行目あたり。コメントアウトされている同種というかそのままの記述の下に追記。

myorigin = $mydomain

116行目あたり。以下の通り調整。

inet_interfaces = localhost
  ↓
inet_interfaces = all

164行目あたり。以下の通り調整。

mydestination = $myhostname, localhost.$mydomain, localhost
  ↓
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

420行目あたり。コメントアウトされている同種の記述の下に追記。

home_mailbox = Maildir/

574行目あたり。コメントアウトされている同種の記述の下に追記。

smtpd_banner = $myhostname ESMTP unknown

 

以下を最下行に追記。

smtpd_sasl_auth_enable = yes

smtpd_recipient_restrictions = 
    permit_mynetworks
    permit_sasl_authenticated
    reject_unauth_destination

 

sudo vi /etc/postfix/master.cf

16行目あたり。コメントアウトをはずす。

#submission inet n - n - - smtpd

  ↓

submission inet n - n - - smtpd

 

19行目あたり。コメントアウトをはずす。

# -o smtpd_sasl_auth_enable=yes

  ↓

 -o smtpd_sasl_auth_enable=yes

 

SMTP認証(sasl使用)

sudo yum -y install cyrus-sasl

起動して,起動時に有効化。

sudo systemctl start saslauthd
sudo systemctl enable saslauthd

 

sudo vi /etc/sasl2/smtpd.conf

1行目。

pwcheck_method: saslauthd

pwcheck_method: auxprop

 

sudo mkdir -p /etc/skel/Maildir/{new,cur,tmp}
sudo chmod -R 700 /etc/skel/Maildir/

 

sudo vi /etc/postfix/main.cf

最終行に以下を追記。

local_recipient_maps =
luser_relay = unknown_user@localhost

 

sudo su
echo unknown_user: /dev/null >> /etc/aliases
exit
sudo newaliases

Postfixを起動。起動時に自動起動

sudo systemctl restart postfix
sudo systemctl enable postfix

 

次にDovecotです。

sudo yum -y install dovecot
sudo vi /etc/dovecot/conf.d/10-mail.conf

30行目あたり。コメントアウトされている同種の記述の下に追記。

mail_location = maildir:~/Maildir


sudo vi /etc/dovecot/conf.d/10-auth.conf
10行目あたりを以下のように調整。

#disable_plaintext_auth = yes

  ↓

disable_plaintext_auth = no

 

sudo vi /etc/dovecot/conf.d/10-ssl.conf

8行目あたり。以下の通り変更。

ssl = required

  ↓

ssl = no

 

Dovecot起動。起動時に自動起動

sudo systemctl start dovecot
sudo systemctl enable dovecot