アットウィキロゴ
CentOS では SMTPサーバー は、デフォルトでは sendmail です。
しかしこの sendmail は設定が難しいので、sendmail互換である Postfix に移行させます。
Maildir 形式が利用しやすいのも、移行の目的の1つです。
  • Postfix のインストール
# yum install postfix
  • sendmail の停止
とりあえず sendmail を停止させておく
# service sendmail stop
sm-client を停止中:                                        [  OK  ]
sendmail を停止中:                                         [  OK  ]
ついでに sendmail の自動起動設定も調べておき、さらに自動起動リストから外す
# chkconfig --list sendmail
sendmail        0:off   1:off   2:on    3:on    4:on    5:on    6:off
# chkconfig --del sendmail
  • main.cf の設定
Postfix では /etc/postfix/main.cf を編集します。
以下はデフォルトに対して編集した箇所です。
myhostname = myhost.mydomain
mydomain = mydomain
myorigin = $myhostname ・・・ このホストで出されたメールのドメイン部分(@より後ろの部分)。通常は $myhostname
inet_interfaces = all ・・・ メールを受け取るネットワークインタフェースのアドレス範囲を指定する。
mydestination = $myhostname, localhost.$mydomain, localhost ・・・ このSMTPサーバーが、最終目的地とみなす範囲。つまりこれ以外は別ホストに転送する。
mynetworks_style = subnet ・・・ 信頼できるSMTPクライアントを指定する。subnnet は自ホストの所属しているサブネットです。
relay_domains = $mydestination ・・・ リレーを許可するドメイン
home_mailbox = Maildir/ ・・・ Maildir 形式を利用する
sendmail_path = /usr/sbin/sendmail ・・・ sendmail互換プログラムのパス。いろいろな CGI などがこのパスを利用しているので、今までの sendmail と同じにする。あとで /usr/sbin/sendmail.postfix と入れ替える必要がある。これにより、CGI側は修正が不要になる。
  • /usr/sbin/sendmail の修正
上述の main.cf の設定で行ったように、/usr/sbin/sendmail が Postfix の sendmail互換プログラムになるように修正が必要です。
# mv /usr/sbin/sendmail /usr/sbin/sendmail.old ・・・ sendmail.old と名前を変更する。
# ln -s /usr/sbin/sendmail.postfix /usr/sbin/sendmail ・・・ シンボリックリンクを張る
  • 自動起動の設定
# chkconfig --add postfix ・・・ 自動起動に追加する
# chkconfig --list postfix ・・・ 自動起動のランレベルを確認する
postfix         0:off   1:off   2:on    3:on    4:on    5:on    6:off
# service postfix start ・・・ サービスを開始する
postfix を起動中:                                          [  OK  ]
最終更新:2008年01月20日 20:55