Xserver VPSでDebianサーバ構築/SMTPサーバ設定

提供: Medeshima wiki
< Xserver VPSでDebianサーバ構築
2024年5月31日 (金) 05:59時点におけるHosakino (トーク | 投稿記録)による版 (→‎設定反映)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
ナビゲーションに移動 検索に移動

概要

次の表のとおりである。

メールサーバ Postfix

設定

以下の順に行う。

証明書

$ sudo certbot certonly --webroot --webroot-path /var/www/html -d www.example.com

または

$ sudo certbot certonly --standalone -d www.example.com

Postfix設定

次のコマンドを実行し、以下の表の設定を行う。

$ sudo apt install postfix libsasl2-modules

※再設定する場合

$ sudo dpkg-reconfigure postfix

メール設定の一般形式 インターネットサイト
システムメール名 example.com
root と postmaster のメール受け取りユーザ mede
メールを受け取るほかの宛先 (なければ空) example.com, HOST, localhost, localhost.localdomain
メールキューの同期更新を強制しますか? いいえ
ローカルネットワーク 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
メールボックスのサイズの制限 (バイト) 0
ローカルアドレス拡張文字 +
利用するインターネットプロトコル すべて

myhostname

  • /etc/postfix/main.cf
myhostname = mail.example.com

その他の設定

  • /etc/postfix/main.cf
smtpd_tls_cert_file=/etc/letsencrypt/live/mail.example.com/fullchain.pem
smtpd_tls_key_file=/etc/letsencrypt/live/mail.example.com/privkey.pem

home_mailbox = Maildir/

smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes

  • /etc/postfix/master.cf
smtps     inet  n       -       y       -       -       smtpd

  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes

  -o smtpd_relay_restrictions=permit_sasl_authenticated,reject

e-mail message submission

submission inet n       -       y       -       -       smtpd

  -o smtpd_sasl_auth_enable=yes

  -o smtpd_relay_restrictions=permit_sasl_authenticated,reject

設定反映

次のコマンドを実行し、設定を反映する。

$ sudo systemctl reload postfix@-

/usr/share/doc/postfix/README.Debian.gz

メール転送設定

次のファイルに、以下の設定を行う。

  • /etc/aliases
root: LOCAL

LOCAL ローカルユーザ名
$ sudo newaliases

バックアップ

  • /etc/postfix
  • ~/Maildir

参考

ローカルメールサーバの場合

サテライトシステム
システムメール名 example.com
SMTP リレーホスト mail.example.com:587
root と postmaster のメール受け取りユーザ mede
メールを受け取るほかの宛先 (なければ空) HOST, HOST, localhost.localdomain, localhost
メールキューの同期更新を強制しますか? いいえ
ローカルネットワーク 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
メールボックスのサイズの制限 (バイト) 0
ローカルアドレス拡張文字 +
利用するインターネットプロトコル すべて

myhostname

  • /etc/postfix/main.cf
myhostname = HOST

HOSTにドメイン名が付いていると、うまく動かない?

スマートホスト

  • /etc/postfix/main.cf
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/example_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_mechanism_filter = plain
smtp_use_tls = yes

スマートホストパスワード設定

次のファイルに、以下の設定を行う。

  • /etc/postfix/example_passwd
mail.example.com:587 mede:PASS

PASS パスワード
$ sudo postmap mede_passwd
$ sudo rm mede_passwd
$ sudo chmod 600 mede_passwd.db

  • /etc/aliases
root: mede
mede: mede@example.com