Ubuntu 21.04
Sponsored Link

Mail サーバー : Postfix インストール2021/05/21

 
Postfix をインストールして SMTP サーバーを構築します。SMTP は [25/TCP] を使用します。
[1] メール不正中継防止に、後述の Dovecot の SASL機能を利用し、送信にも認証が必要なように Postfix を設定します。
root@mail:~#
apt -y install postfix sasl2-bin
# 一般的な構成設定の選択を求められるが

# 当例では後ほど手動設定するため [No Configuration] を選択

+------+ Postfix Configuration +-------+
| General type of mail configuration:  |
|                                      |
|       No configuration               |
|       Internet Site                  |
|       Internet with smarthost        |
|       Satellite system               |
|       Local only                     |
|                                      |
|                                      |
|       <Ok>           <Cancel>        |
|                                      |
+--------------------------------------+

root@mail:~#
cp /usr/share/postfix/main.cf.dist /etc/postfix/main.cf

root@mail:~#
vi /etc/postfix/main.cf
# 78行目 : コメント解除

mail_owner = postfix
# 94行目 : コメント解除しホスト名指定

myhostname =
mail.srv.world
# 102行目 : コメント解除しドメイン名指定

mydomain =
srv.world
# 123行目 : コメント解除

myorigin = $mydomain
# 137行目 : コメント解除

inet_interfaces = all
# 185行目 : コメント解除

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
# 228行目 : コメント解除

local_recipient_maps = unix:passwd.byname $alias_maps
# 270行目 : コメント解除

mynetworks_style = subnet
# 287行目 : 自ネットワーク追記

mynetworks = 127.0.0.0/8,
10.0.0.0/24
# 407行目 : コメント解除

alias_maps = hash:/etc/aliases
# 418行目 : コメント解除

alias_database = hash:/etc/aliases
# 440行目 : コメント解除

home_mailbox = Maildir/
# 576行目 : コメントにしてその下に追記

#
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_banner = $myhostname ESMTP
# 650行目 : 追記

sendmail_path =
/usr/sbin/postfix
# 655行目 : 追記

newaliases_path =
/usr/bin/newaliases
# 660行目 : 追記

mailq_path =
/usr/bin/mailq
# 666行目 : 追記

setgid_group =
postdrop
# 670行目 : コメント化

#
html_directory =
# 674行目 : コメント化

#
manpage_directory =
# 679行目 : コメント化

#
sample_directory =
# 683行目 : コメント化

#
readme_directory =
# 684行目 : IPv6 もリスンする場合は [all] に変更

inet_protocols = ipv4
# 最終行へ追記

# 例として 送受信メールサイズを 10M に制限
message_size_limit = 10485760

# SMTP-Auth 設定
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_mynetworks, permit_auth_destination, permit_sasl_authenticated, reject 

root@mail:~#
root@mail:~#
systemctl restart postfix

関連コンテンツ