Postfixメールサーバです。sendmailはめんどくさいので、これを使います。 環境設定postfixはインストールされている可能性がありますので、 rpm -qa | grep postfix で確認します。バージョンが怪しかったので、とりあえずけしておきました。 rpm -qa | grep postfix | xargs rpm -e ではここからhttp://www.postfix.org/download.htmlダウンロードします。postfix-2.1.5.tar.gzを落としました。とりあえず展開しましょう。その後makeです。 tar xzvf postfix-2.1.5.tar.gz make そしてpostfixを管理するユーザとグループを作成します。 groupadd postdrop useradd -g postdrop -d /dev/null -s /bin/false postfix postfixユーザはホームもなければシェルも触れないようにしておきます。その後 make install あれ?エラーがでました。 postfix: fatal: file /etc/postfix/main.cf: parameters mail_owner and etgid_group: user postfix and group postdrop have the same group ID: 503 とりあえず、/etc/groupでpostdropのIDを変更して、再度make installをしました。 その後/etc/postfix/main.cfを編集します。 myhostname = hidekazu.dhs1.sst.ne.jp ホスト名 mydomain = dhs1.sst.ne.jp ドメイン名 inet_interfaces = all すべて受信 local_recipient_maps = proxy:unix:passwd.byname $alias_maps ローカルユーザの存在をチェックし、不明なユーザは受信を拒否する mydestination = $myhostname, localhost.$mydomain, $mydomain メールの宛先として受け入れるホスト名の設定 mynetworks_style = subnet IP空間の設定 mynetworks = 192.168.1.0/24, 127.0.0.0/8 この範囲のクライアントはメールをリレーすることができる。 smtpd_banner = $myhostname ESMTP $mail_name メールヘッダに記載されるMTAの表示の設定 relay_domains = $mydestination 信頼されない(mynetworks)のクライアント以外のメールは$mydestinationの範囲内しか配送しない。 home_mailbox = Maildir/ 各ユーザのホームディレクトリ内にMaildirをおく Maildirとは1メッセージ=1ファイルの形式である。 smtpd_helo_required = yes HELOコマンドでホスト名を通知しないホストを拒否 smtpd_client_restrictions = permit_mynetworks, reject_unknown_client, permit mynetworksは許可。逆引きができないホストの接続を拒否 設定後、起動、停止、再起動の確認をします。 /usr/sbin/postfix start /usr/sbin/postfix stop /usr/sbin/postfix reload また25番ポートが開いているかも確認しておきます。 nmap localhost ではtelnetから Trying 127.0.0.1... Connected to localhost.localdomain. Escape character is '^]'. 220 hidekazu.dhs1.sst.ne.jp ESMTP Postfix HELO localhost --->開始メッセージ 250 hidekazu.dhs1.sst.ne.jp MAIL FROM: test@localhost --->送信者 250 Ok RCPT TO: test2@localhost --->受信者 250 Ok DATA --->ボディ入力 354 End data with <CR><LF>.<CR><LF> ugoitekure. . --->メッセージ終了 250 Ok: queued as 2852DFE005 QUIT --->終わり するとtest2のホームディレクトリのMaildirにnewというディレクトリがあるので、のぞいてみましょう。また、/var/log/maillogにログが残っていますので、確認しておきます。 qpopperSMTPからメールを取り出すためのPOPサーバです。 http://www.eudora.com/products/unsupported/qpopper/index.htmlからダウンロードします。ちょっとわかりにくいかもしれない場合はftp://ftp.qualcomm.com/eudora/servers/unix/popper/からqpopper4.0.5.tar.gzをダウンロードします。またその前にPOP before SMTPを使いたいので、http://pocketstudio.jp/drac-ja/index.htmlより、DRACをダウンロードしておきます。 wget ftp://ftp.cc.umanitoba.ca/src/drac.tar.Z mkdir drac cd drac tar xzvf ../drac.tar.Z ではMakefileを修正します。http://pocketstudio.jp/drac-ja/compile.htmlを参考にしました。 INSTALL = install EBIN = /usr/local/sbin MAN = /usr/local/man/man DEFS = -DSOCK_RPC -DFCNTL_LOCK -DGETHOST -DDASH_C CC = gcc RANLIB = : CFLAGS = $(DEFS) -g LDLIBS = -ldb TSTLIBS = -L. -ldrac -lnsl RPCGENFLAGS = -C -I MANLIB = 3 MANADM = 8 修正できましたら、 make make install make install-man cp libdrac.a /usr/local/lib cp dracd-setup.linux /etc/init.d/dracd ちょっとdracdを修正します。 daemon rpc.dracd& を daemon /usr/local/sbin/rpc.dracd -i -e 30& にしました。-iは起動時にdatabaseを初期化します。 -eは承認の有効期限を30分にしています。またchkconfigを使用する場合は、ヘッダを #!/bin/bash # # dracd Startup script for the dracd # # chkconfig: - 87 15 # description: dracd # processname: dracd # # Put this file into /etc/rc.d/init.d/dracd # and link it intot he run levels you want to use it # by doing "ln -s /etc/rc.d/init.d/dracd /etc/rc.d/rc.<runlevel>/S99dracd" # # dracd-setup にでもして、chkconfig --add dracdして、chkconfig --level 345 dracd onとでもしておきます。では、dracd.allowを編集しましょう。まずコピーして、 cp dracd.allow-sample /etc/mail/dracd.allow emacs /etc/mail/dracd.allow で編集し、 #255.255.255.255 192.168.16.8 #<--コメント 255.255.255.255 127.0.0.1 ではqpopperです。 tar xzvf qpopper4.0.5.tar.gz で解凍して、解凍したディレクトリに移動後、 adduser pop ./configure --with-popuid=pop ここで、dracを使用する場合は、--enable-drac、--enable-apop=/etc/pop.authでAPOPです。 make make insatll を実行します。/usr/local/sbinにpopperがインストールされてます。 popauthで、APOP用のパスワードを設定します。 popauth -init で初期化し、 popauth -user hogeuser でパスワード設定です。 次に/etc/xinetd.dにpopperという名前で作成します。 service pop3 { socket_type = stream wait = no only_from = 127.0.0.1 user = root server = /usr/local/sbin/popper server_args = -S -s -R disable = no }
Courier-IMAP認証用のライブラリとしてCourier authentication libraryをいれておきます。 http://www.courier-mta.org/からCourier authentication libraryをダウンロードします。 wget http://superb-west.dl.sourceforge.net/sourceforge/courier/courier-authlib-0.58.tar.bz2 tar xvjf courier-authlib-0.58.tar.bz2 cd courier-authlib-0.58 ./configure --with-redhat make configure: error: Cannot find either the gdbm or the db library. んー エラーがでました。とりあえず、OpenLDAPでgdbmをいれてますので、いれておきます。 make install make install-migrate make install-configure 詳しくはINSTALLにかかれてます。 では、Courier-IMAPです。http://www.courier-mta.org/download.phpからダウンロードします。courier-imap-3.0.8.20041129.tar.tarを解凍します。(2006/05/13時点で4.1.0です)解凍後、rootではインストールできないので、別のユーザでになりましょう。またCourier authentication libraryもいるので、ダウンロードしておきます。--with-redhatをつけておかないと、rpmを作れと怒られるので、つけておきましょう。 wget http://surfnet.dl.sourceforge.net/sourceforge/courier/courier-imap-4.1.0.tar.bz2 tar xvjf courier-imap-4.1.0.tar.bz2 cd courier-imap-4.1.0 ./configure --prefix=/usr/local --with-redhat --without-authmysql --without-authldap --with-db=db --without-ipv6 rootでは怒られます。また--with-redhatをつけないとrpmを作れといわれます。 ※Ver3の時 Courier authenticationに移動して、 ./configure --with-redhat make install make install-migrate make install-configure courier-imap ./configure --prefix=/usr/local/courier-imap make make install make install-configure /usr/local/courier-imap/libexec/pop3d.rc start /usr/local/courier-imap/libexec/imapd.rc start http://www.aconus.com/~oyaji/mail2/courier-imap.htm cyrus-SASLSMTPAuthに対応するということで、ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/からFile: cyrus-sasl-2.1.21.tar.gzをダウンロードしました。 wget ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-2.1.21.tar.gz cd cyrus-sasl-2.1.21 ./configure --enable-login=yes # --enable-login=yesはOutlookExpressでPlain認証を利用する場合に必要です。 make make install ln -s /usr/local/lib/sasl /usr/lib/sasl ではpostfixを。 groupadd postdrop #管理用 groupadd postfix #管理用 useradd -g postfix -d /dev/null -s /bin/false postfix #管理用 cd postfix-2.2.5 make tidy #以前コンパイルして残っている場合は、tidyをつけて実行 make makefiles CCARGS="-DUSE_SASL_AUTH -I/usr/local/include/sasl" AUXLIBS="-L/usr/local/lib -lsasl2" make install セキュリティウィルスチェックhttp://www.g-ninja.net/freebsd/clamav.html バーチャルドメインvirtual mailbox チェックhttp://www.abuse.net/relay.html メモsmtp inet n - n - - smtpd 587 inet n - n - - smtpd http://nekojita.org/hiki/Postfix.html リンクhttp://solaris.bluecoara.net/servers/postfix/virtual2.phtml 参考書籍 |