Fedora 19
Sponsored Link

Postfix インストール/設定2013/07/11

 
Postfixを使ってSMTPサーバーを構築します。メール不正中継防止に後述のDovecotのSASL機能を利用し、送信にも認証が必要なように設定します。
[1] Postfix のインストールと設定
[root@mail ~]#
yum -y install postfix
[root@mail ~]#
vi /etc/postfix/main.cf
# 75行目:コメント解除しホスト名指定

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

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

myorigin = $mydomain
# 116行目:変更

inet_interfaces =
all
# 164行目:追記

mydestination = $myhostname, localhost.$mydomain, localhost
, $mydomain
# 264行目:コメント解除し自ネットワーク追記

mynetworks = 127.0.0.0/8,
10.0.0.0/24
# 419行目:コメント解除しMaildir形式へ移行

home_mailbox = Maildir/
# 548行目:コメント解除; 549行目:追記 ( メールボディチェック )

header_checks = regexp:/etc/postfix/header_checks
body_checks = regexp:/etc/postfix/body_checks
# 574行目:追記

smtpd_banner = $myhostname ESMTP
# 最終行へ追記

# 送受信メールサイズを10Mに制限

message_size_limit = 10485760

# メールボックスサイズを1Gに制限

mailbox_size_limit = 1073741824
# 以下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_client_restrictions = permit_mynetworks, reject_unknown_client, permit
smtpd_recipient_restrictions = permit_mynetworks, permit_auth_destination, permit_sasl_authenticated, reject
[root@mail ~]#
vi /etc/postfix/header_checks
# ファイルの最初にでも追記

# 例として、example.com からのメール拒否

/^From:.*@example\.com/ REJECT
[root@mail ~]#
vi /etc/postfix/body_checks
# 例として、本文にexample.comが含まれていたら拒否

/^(|[^>].*)example.com/ REJECT
[root@mail ~]#
systemctl stop sendmail.service

[root@mail ~]#
systemctl disable sendmail.service

[root@mail ~]#
alternatives --config mta
 
# デフォルトMTA変更


There are 2 programs which provide 'mta'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/sbin/sendmail.sendmail
   2           /usr/sbin/sendmail.postfix
Enter to keep the current selection[+], or type selection number:
2
 
# postfixに切り替え
[root@mail ~]#
systemctl start postfix.service

[root@mail ~]#
systemctl enable postfix.service

関連コンテンツ