「Xserver VPSでDebianサーバ構築/SMTPサーバ設定」の版間の差分
ナビゲーションに移動
検索に移動
(→概要) |
(→設定反映) |
||
(同じ利用者による、間の19版が非表示) | |||
9行目: | 9行目: | ||
= 設定 = |
= 設定 = |
||
以下の順に行う。 |
|||
== 証明書 == |
|||
<nowiki> |
|||
$ sudo certbot certonly --webroot --webroot-path /var/www/html -d www.example.com |
|||
</nowiki> |
|||
または |
|||
<nowiki> |
|||
$ sudo certbot certonly --standalone -d www.example.com |
|||
</nowiki> |
|||
== Postfix設定 == |
|||
次のコマンドを実行し、以下の表の設定を行う。 |
|||
<nowiki> |
|||
$ sudo apt install postfix libsasl2-modules |
|||
</nowiki> |
|||
※再設定する場合 |
|||
<nowiki> |
|||
$ sudo dpkg-reconfigure postfix |
|||
</nowiki> |
|||
{| class="wikitable" |
|||
|メール設定の一般形式 |
|||
|インターネットサイト |
|||
|- |
|||
|システムメール名 |
|||
|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 |
|||
<nowiki> |
|||
myhostname = mail.example.com |
|||
</nowiki> |
|||
=== その他の設定 === |
|||
* /etc/postfix/main.cf |
|||
<nowiki> |
|||
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 |
|||
</nowiki> |
|||
* /etc/postfix/master.cf |
|||
<nowiki> |
|||
smtps inet n - y - - smtpd |
|||
-o smtpd_tls_wrappermode=yes |
|||
-o smtpd_sasl_auth_enable=yes |
|||
-o smtpd_relay_restrictions=permit_sasl_authenticated,reject |
|||
</nowiki> |
|||
=== e-mail message submission === |
|||
<nowiki> |
|||
submission inet n - y - - smtpd |
|||
-o smtpd_sasl_auth_enable=yes |
|||
-o smtpd_relay_restrictions=permit_sasl_authenticated,reject |
|||
</nowiki> |
|||
=== 設定反映 === |
|||
次のコマンドを実行し、設定を反映する。 |
|||
<nowiki> |
|||
$ sudo systemctl reload postfix@- |
|||
</nowiki> |
|||
/usr/share/doc/postfix/README.Debian.gz |
|||
== メール転送設定 == |
|||
次のファイルに、以下の設定を行う。 |
|||
* /etc/aliases |
|||
<nowiki> |
|||
root: LOCAL |
|||
</nowiki> |
|||
{| class="wikitable" |
|||
|LOCAL |
|||
|ローカルユーザ名 |
|||
|} |
|||
<nowiki> |
|||
$ sudo newaliases |
|||
</nowiki> |
|||
== バックアップ == |
|||
* /etc/postfix |
|||
* ~/Maildir |
|||
= 参考 = |
|||
== ローカルメールサーバの場合 == |
|||
{| class="wikitable" |
|||
| |
|||
|サテライトシステム |
|||
|- |
|||
|システムメール名 |
|||
|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 |
|||
<nowiki> |
|||
myhostname = HOST |
|||
</nowiki> |
|||
HOSTにドメイン名が付いていると、うまく動かない? |
|||
=== スマートホスト === |
|||
* /etc/postfix/main.cf |
|||
<nowiki> |
|||
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 |
|||
</nowiki> |
|||
==== スマートホストパスワード設定 ==== |
|||
次のファイルに、以下の設定を行う。 |
|||
* /etc/postfix/example_passwd |
|||
<nowiki> |
|||
mail.example.com:587 mede:PASS |
|||
</nowiki> |
|||
{| class="wikitable" |
|||
|PASS |
|||
|パスワード |
|||
|} |
|||
<nowiki> |
|||
$ sudo postmap mede_passwd |
|||
$ sudo rm mede_passwd |
|||
$ sudo chmod 600 mede_passwd.db |
|||
</nowiki> |
|||
* /etc/aliases |
|||
<nowiki> |
|||
root: mede |
|||
mede: mede@example.com |
|||
</nowiki> |
2024年5月31日 (金) 05:59時点における最新版
概要
次の表のとおりである。
メールサーバ | 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