Archive for the 'postfix' Category

postfix:インストールとmtaの切り替え

sendmailが入っているサーバにpostfixを入れるメモ。

まず、postfixのインストール

# yum install postfix

次に設定。/etc/postfix/main.cfに記述する。

# cp /etc/postfix/main.cf /etc/postfix/main.cf.org
# vi /etc/postfix/main.cf
/etc/postfix/main.cf
myhostname = 自ホスト名
mydomain = $mydomain
myorigin = $mydomain
#inet_interfaces = all
inet_interfaces = localhost
mynetworks_style = host
mynetworks = xxx.xxx.xxx.xxx
smtpd_banner = $myhostname ESMTP
home_mailbox = Maildir/
main.cfのパラメタ抜粋
パラメータ名 説明
myhostname 自ホスト名
DNSで引けるドメイン名であること。
mydomain 自ドメイン名
postfixの名前解決に使用する。ホスト名を省略したとき、このlocalhost.$mydomainに送信される。
mynetworks_style 信頼できるSMTPクライアントアドレス
host,subnet,classが指定できる。
mynetworks 信頼できるSMTPクライアントアドレス
mynetworks_styleよりも詳細に設定するときに使う。,(カンマ)またはスペースで区切ってsabunetをいくつも設定できる。ここを設定するとmynetworks_styleは無視される。
home_mailbox mailboxの形式

mtaの切り替え。

# /usr/sbin/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:

ここでpostfix・・・2を選ぶ。

設定したらpostfixを起動&initスクリプトの登録。

# /etc/init.d/postfix start
# /sbin/chkconfig postfix on

sendmailは止める。

# /etc/init.d/sendmail stop
# /sbin/chkconfig sendmail off

必ず不正中継のテストをすること。 Mail relay testing

postfix:メールの保存形式と設定方法

postfixはメールをmbox、MailDir形式、cyrus形式で保存できる。デフォルトの設定ではmbox形式。

mbox、MailDirの違いはざっと↓。

mbox
全てのメールを1ファイルで保存する。
ファイルサイズは非常に大きくなる。サイズの大きくなったmboxにアクセスするとサーバ負荷は高くなる。
全てのメールが1ファイルで保存されているのでファイルが壊れたときの影響が大きい。また排他処理も同様の理由で不利である。

MailDir
ユーザディレクトリのMailDirフォルダ以下に1メールを1ファイルで保存する。
mbox形式の弱点が解消されるほか、MailDirフォルダに容量制限をかけることが出来る。
欠点はファイル増加によるパフォーマンス低下。

cyrus(よく解りません・・・)
ユーザディレクトリ以外の場所に1メールを1ファイルで保存する。
連携できるアプリが多いのが長所みたい。

設定方法
1.main.cfを編集してメールの保存方法を設定します。

/etc/postfix/main.cf
#home_mailbox = Mailbox
#home_mailbox = Maildir/
mbox形式ならMailbox、MailDir、cyrus形式ならMaildir/をコメントアウトする
※Maildir/は”/まで”必要!

2.postfixを再起動する
/etc/init.d/postfix restart

参考サイト: posyfixのぺーじ