CentOSにPostfixをインストールした時の手順です。
メールの不正リレー対策として、SMTP-AUTHを組み込みます。
- CentOSにPostfixをyumを利用してインストールします。
yum install postfix
- MTAをSendmailからPostfixに変更します。
/etc/init.d/sendmail stop
chkconfig --del sendmail
リストからPostfixを選択します。
alternatives --config mta
- main.cfの設定vi /etc/postfix/main.cf
# myhostname - ホスト名の定義
myhostname = host.example.jp
# mydomain - ドメイン名の定義
mydomain = example.jp
# myorigin - ローカルからメール配信するときの送信元アドレスの定義
# user@example.jp 形式にするなら myorigin = $mydomain
# user@host.example.jp 形式にするなら myorigin = $myhostname
myorigin = $mydomain
# inet_interfaces - メール受信するインタフェイスの設定
# デフォルトではローカルからの配信しか受け付けない。
# リモートからメールを受け取れるようにするなら以下の記述を入れる。
inet_interfaces = all
# mydestination - どのメールアドレスをローカル配信するかの定義。
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks_style = subnet
# mynetworks - メールリレーを受け付けるクライアントアドレスの設定
mynetworks = 127.0.0.0/8
// メールサーバー名の隠蔽化
smtpd_banner = $myhostname ESMTP unknown
# メール格納場所の指定(Courier-IMAPの場合は必ずMaildir/を指定)
home_mailbox = Maildir/
# エリアス設定を行うファイルの指定
alias_maps = hash:/etc/aliases
// SMTP-Auth設定
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $mydomain
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
broken_sasl_auth_clients = yes
- SMTP-Auth設定(SMTP-Auth用ユーザ/パスワードにシステムのユーザ/パスワードを使用する場合)vi /usr/lib/sasl2/smtpd.conf
pwcheck_method: saslauthd
mech_list: plain login
- 自動起動の設定
/etc/init.d/saslauthd start
chkconfig saslauthd on
/etc/init.d/postfix start
chkconfig postfix on
- yumでダウンロードしたパッケージの削除
yum clean packages