fc2ブログ
ホーム   »  Unix/Linux  »  Postfix 2.3 セットアップ

Postfix 2.3 セットアップ

CentOS 5 には安定と実績の (一度設定したらあまり触りたくないとも言う) sendmail が標準でインストールされていますが、システム開発で使用するのであれば拡張アドレスの使える Postfix の方が良いと思っております。 そんなわけでこの記事では Sendmail を Postfix に入れ替える方法を記述しております。

OSCentOS 5.5 final Kernal 2.6.18-194.el5xen
MTAPostfix 2:2.3.3-2.3.el5_6

Postfix のインストール

Postfix については取り立ててモジュール構成にこだわりもないので yum でインストールしています (セキュリティレベルが高いシステムで常に最新パッチを当てなければならない場合はソースビルドにしておいた方が良いと思います)。

torao@safran$ yum install postfix
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * addons: ftp.iij.ad.jp
 * base: ftp.iij.ad.jp
…

MTA の入れ替え

CentOS はデフォルト構成で sendmail が起動していますので、停止してデフォルト MTA を Postfix に変更します。

torao@safran$ /etc/init.d/sendmail stop
Shutting down sm-client:                                   [  OK  ]
Shutting down sendmail:                                    [  OK  ]
torao@safran$ chkconfig --list sendmail
sendmail        0:off   1:off   2:on    3:on    4:on    5:on    6:off
torao@safran$ chkconfig sendmail off
torao@safran$ alternatives --config 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 の設定

Postfix の設定ファイルを編集してインターフェースやらドメインやらを設定。

torao@safran$ vim /etc/postfix/main.cf
myhostname = safran.bjorfuan.com
mydomain = bjorfuan.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, lcoalhost, $mydomain
mynetworks = 192.168.xxx.xxx/24, 127.0.0.0/8
recipient_delimiter = +
home_mailbox = mailbox/

Postfix を起動します。

torao@safran$ /etc/init.d/saslauthd start
Starting saslauthd:                                        [  OK  ]
torao@safran$ chkconfig saslauthd on
torao@safran$ /etc/init.d/postfix start
Starting postfix:                                          [  OK  ]
torao@safran$ chkconfig postfix on

SELinux の設定

初期状態では SELinux の制限が有効になっており Postfix プロセスがユーザのメールボックスに書きこむことができません。SELinux を無効化するには以下の設定を行って OS を再起動するか:

torao@safran$ vim /etc/selinux/config
SELINUX=disabled
SELINUXTYPE=targeted

または system-config-securitylevel-tui コマンドで変更することができます。SELinux を無効化しないで Postfix の書き込み許可だけを与える設定は… 挫折しました orz。

なお SELinux の制限によりメールの保存が出来なかった場合は /var/log/maillog に以下のようなログが出力されます。

Aug 10 21:13:48 safran postfix/local[29549]: warning: maildir access problem for UID/GID=500/100: create maildir file /home/xxx/mailbox/tmp/1312959828.P29549.safran: Permission denied
Aug 10 21:13:48 safran postfix/local[29549]: warning: perhaps you need to create the maildirs in advance
Aug 10 21:13:48 safran postfix/local[29549]: 2E3A0436F54: to=<xxx@yyy.com>, orig_to=<torao>, relay=local, delay=0.03, delays=0.02/0/0/0.01, dsn=5.2.0, status=bounced (maildir delivery failed: create maildir file /home/torao/mailbox/tmp/1312959828.P29549.safran: Permission denied)
コメント
トラックバック
トラックバック URL
コメントの投稿
管理者にだけ表示を許可する
Profile
Takami Torao
Takami Torao
C/C++ 使いだった 1996年、運命の Java と出会い現在に至る。のらアーキテクト。
Yah, this is image so I don't wanna eat spam, sorry!
Search

Google
MOYO Laboratory
Web

カテゴリー
最近の記事
最近のコメント
最近のトラックバック
月別アーカイブ
ブロとも申請フォーム
RSSフィード
リンク