ページ更新: 2005-01-29 (土) (5875日前)
関連: Linux/Debian, Linux/Postfix (2001-06-19作成) 送信能力に優れているpostfixをメールマガジンなどの送信専用にインストールしてみました。 目的は、サーバの既存環境にできるだけ影響を与えずに送信のチューニングをするため。 (CGIからの送信をスプールして、CGI終了直前にスプール内のメールを送信、とか) テスト環境は Debian GNU/Linux Woody + postfix 20010228-pl3 (tar.gz版)です。 本番環境は Sun Cobalt などのサーバを想定してますので、Debianパッケージを使わず、ソースコードからインストールしました。 もし、Debian上に、Debianのパッケージを使ってインストールし、既存のMTAと共存させたいのであれば、 chroot環境を用意してその中にdebootstrapでインストールすればよいと思われます。試してませんが。
目次 [編集]情報源 #
インストール・設定・動作確認 #postfixのソースコードを入手します。 今回は安定版 Postfix Release 20010228 Patchlevel 03 (958KB) postfix-20010228-pl03.tar.gz を使いました。 アーカイブを展開します。 $ tar zxvf postfix-20010228-pl03.tar.gz $ cd postfix-20010228-pl03 既存環境と干渉させたくないので、設定ファイルの位置を /usr/local/etc/postfix に変更します。 $ make makefiles CCARGS=-DDEF_CONFIG_DIR=\\\\\\\"/usr/local/etc/postfix\\\\\\\" コンパイルします。 $ make インストールします。(sudo 使えるようにしときゃ良かったなあ) 途中でパス名をいくつか聞かれますので、/usr/local 以下を指示しました。 $ su # make install : install_root: [/] tempdir: [/home/admin/postfix/postfix-20010228-pl03] config_directory: [/etc/postfix] /usr/local/etc/postfix daemon_directory: [/usr/libexec/postfix] /usr/local/libexec/postfix command_directory: [/usr/sbin] /usr/local/sbin queue_directory: [/var/spool/postfix] sendmail_path: [/usr/lib/sendmail] /usr/local/sbin/sendmail newaliases_path: [/usr/bin/newaliases] /usr/local/sbin/newaliases mailq_path: [/usr/bin/mailq] /usr/local/sbin/mailq mail_owner: [postfix] setgid: [no] manpages: [/usr/local/man] Updating /usr/local/libexec/postfix/bounce... : Postfixのsmtpdを使わないので、master.cf の次の行をコメントアウトします。 (さらにローカルデリバリエージェント local も止めても良いかも) #smtp inet n - n - - smtpd main.cf を修正します。myhostname さえ修正すればpostfixを起動できますが、既存の環境と干渉する部分も修正しました。
main.cf を検査します。 # /usr/local/sbin/postfix check (1度目) postfix-script: warning: creating missing Postfix pid directory postfix-script: warning: creating missing Postfix incoming directory postfix-script: warning: creating missing Postfix active directory postfix-script: warning: creating missing Postfix bounce directory postfix-script: warning: creating missing Postfix defer directory postfix-script: warning: creating missing Postfix deferred directory postfix-script: warning: creating missing Postfix flush directory postfix-script: warning: creating missing Postfix saved directory postfix-script: warning: creating missing Postfix corrupt directory postfix-script: warning: creating missing Postfix public directory postfix-script: warning: creating missing Postfix private directory # /usr/local/sbin/postfix check (2度目) # postfix を起動します。 # /usr/local/sbin/postfix start メールの送信テストを行った後、キューを確認します。 $ /usr/local/sbin/sendmail test@********* From: ********** Subject: ************* test test test . メールがすぐに送信されたので、キューは空です。 $ /usr/local/sbin/mailq Mail queue is empty[編集] 配送を遅延させる #即時配信を停止しqueueにためるようにしてみます。 これはCGIから多数のメールを出すときにCGIが postfixのsendmailコマンドの終了待ちにならないため。 (sendmailだと sendmail -O DeliveryMode=q に当たります) (とはいえ sendmailと違っていったん maildrop に入るのだから、何も対策をしなくてもよいのかも。) 付属のPostfix-FAQの「Running Postfix on a dialup machine」によると、defer_transports って設定があるので、main.cf に追加。 パラメータにはmaster.cfにある「各配送方法」のうち、deferするものを指定。今回はsmtpを指定しました。 defer_transports = smtp 設定確認を行い、エラーがなければ設定を読み込ませます。 (postfix checkって、apacheの apachectl configtest よりはいい加減な気がするなあ) # /usr/local/sbin/postfix check # /usr/local/sbin/postfix reload テスト送信します。 $ /usr/local/sbin/sendmail test@********* From: ********** Subject: ************* test test test . queueの内容を確認します。 ちゃんと queue に溜まっています。 $ /usr/local/sbin/mailq -Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient------- 5C0CF4A717 255 Tue Jun 19 20:47:22 *****@*****.****** (deferred transport) *******@****.***.*** -- 0 Kbytes in 1 Request. queueをフラッシュ(メール送信)し、queueを確認します。キューが空になっています。 $ /usr/local/sbin/sendmail -q $ /usr/local/sbin/mailq Mail queue is empty[編集] Virtual-Domain (From/Sender/Reply-toなどの変更) #virtual-domainの設定です。今回は送信時のアドレスのみ処理します。 Postfixのsendmailコマンドの -F / -f /-t オプションでカバーできるかもしれませんが、念のため調べます。 この処理には Canonical address mapping を使用します。 (この処理はsendmailだとVirtual Hosting with Sendmail の 6.と 7. の作業、 FEATURE(`genericstable') と GENRICS_DOMAIN_FILE に該当します。) main.cfにsender_canonical_mapsを追加します。 sender_canonical_maps = hash:/usr/local/etc/postfix/sender_canonical sender_canonicalを作成します。項目は元のアドレス、書き換え後のアドレス、の順です。 mail1@example.jp mail1@hogehoge1.jp mail2@example.jp mail2@hogehoge2.jp mail3@example.jp mail3@hogehoge3.jp postmap で hash作成し、postfix の設定を更新します。 # /usr/local/sbin/postmap sender_canonical # /usr/local/sbin/postfix reload[編集] 送信のチューニング #この件は UNIX USER 2000/11 「Setting Up FreeBSD 管理者編 第33回 Postfixの詳細設定」でちょっとだけ触れられています。 しかし、しばらくは標準設定で稼働させて、配送状況を見てからチューニングするつもりです。 なお、今回はメールの送信はcgiやcronでキックします。 よって、postfixにメールを渡す前の時点で、送信を高速にすべくあらかじめ次の処理を行っておきます。
|