nomurabbitのブログ

nomurabbitのブログはITを中心にした技術ブログです。

nomurabbitのブログ

Linux環境構築(CentOS5.11)~その5~

<はじめに>
Linux環境構築シリーズ(CentOS5編)その4です。

気が向いたのでPostfixをインストールして、

Outlook2007をメーラーとして自分から自分宛にメールを送れるところまでやります。


<作業内容>
何はともあれPostfixをインストール

Postfixの設定ファイルは下記なので、

適当に設定を行います。

/etc/postfix/main.cf

myhostname = ほげほげ

mydomain = ふがふが.local.jp

myorigin = $mydomain

inet_interfaces = all
※よくわかりませんが、allでないと動きませんでした。

home_mailbox = Maildir/

smtpd_banner = $myhostname ESMTP unknown

smtpd_sasl_auth_enable = yes

smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd

smtp_sasl_mechanism_filter = plain

smtpd_sasl_local_domain = $myhostname

smtpd_recipient_restrictions =
permit_mynetworks
permit_sasl_authenticated
reject_unauth_destination

message_size_limit = 10485760

SMTP-Auth認証を利用するので、cyrus-saslをyumかなんかでインストールして起動!

/usr/lib/sasl2/smtpd.confをこんな感じに編集して、

pwcheck_method: saslauthd
mech_list: CRAM-MD5 PLAIN LOGIN

新規ユーザー作成時にメールボックスも作成されるようにします。

mkdir -p /etc/skel/Maildir/{new,cur,tmp}
chmod -R 700 /etc/skel/Maildir/

これでPostfixを起動させればおkのはず。

あと、POPサーバーとしてdovecotyumかなんかでインストールして、

/etc/dovecot.confを下記のように編集

protocols = imap imaps pop3 pop3s

mail_location = maildir:~/Maildir

そしてdovecotを起動

ユーザーの追加は普通にuseraddで追加して、

useradd -s /sbin/nologin centos

パスワード決めて、saslに登録してやって

saslpasswd2 -p -u ほげほげ.ふがふが.local.jp -c ユーザー名

sasldb2のグループを変えてやればおk!

chgrp postfix /etc/sasldb2

あとはメーラーでアカウント作ってテストして、

ちゃんと送受信できればおk!

<まとめ>
とりあえずPostfixの触りだけですが、

一応構築ができました。

メールサーバーが立つとそれなりにログもたまるので、

(/var/log/maillog)

次回はいよいよ、いかにログを可視化し、監視できるかというのをやっていきます。

まずはCGIで作って、最終的にはZABBIX入れるとかそんな感じでやるつもりです。