メール送信速度の制御(制限)ができるmilter-limitですが、Googleで検索しても日本語のドキュメントが出てこないので、せっかくなのでインストール方法を書いてみます。
まず、SnertSoftのDOWNLOADのページから
(ユーザ登録が必要です。)
・milter-limit/0.12
・LibSnert
の二つをダウンロードする
いよいよmilter-limitのインストール
でインストール完了
次はsendmail.cfを作成する。
sendmail.mcに以下を追記する
以下のコマンドでsendmail.cfをつくり、cfを所定の場所に配置する。
ファイルの権限などが以下のようになっているか確認する。
/etc/mail/ root:smmsp 0750 drwxr-x---
/etc/mail/access.db root:smmsp 0640 -rw-r-----
/etc/mail/sendmail.cf root:smmsp 0640 -rw-r-----
/etc/mail/milter-limit.cf root:root 0644 -rw-r--r--
/var/run/milter/milter-limit.pid milter:milter 0644 -rw-r--r--
/var/run/milter/milter-limit.socket milter:milter 0644 srw-r--r--
/var/db/milter-limit milter:milter 0644 -rw-r--r-- (*BSD)
/var/cache/milter-limit milter:milter 0644 -rw-r--r-- (linux)
/usr/local/libexec/milter-limit root:milter 0550 -r-xr-x---
1秒に1通などという制限をかけて送信する場合には
に
などのように記述し、
として、DBを作成する。
※その後、milter-limitの再起動を忘れないように!
また、1秒間隔で送信制限をしたいなどという時にはQueueRunnerの間隔の変更が必要
(QueueRunnerが動いたタイミングでキューがフラッシュされる)
の部分を
などに変更する。
(1秒間隔でキューをフラッシュするとキューフォルダにあるメールすべてが再試行され、そのときにかなり大量のログを吐き出すので、注意!)
また、起動スクリプトの中で
の中の設定が優先になっているので、
と書き換えて完了。
まず、SnertSoftのDOWNLOADのページから
(ユーザ登録が必要です。)
・milter-limit/0.12
・LibSnert
の二つをダウンロードする
Berkley.dbが無い場合にはインストールをしておく。
cd (path to)/db-4.3.27/build_unix
../dist/configure
make
make install
sendmailを前もってインストールしておく
cd (path to)/sendmail-8.13.4
vi devtools/Site/site.config.m4
sh Build -c
sh Build install
libmilterをインストールしておく
cd (path to)/sendmail-8.13.4/libmilter
sh Build -c
sh Build install
※ここまでは他のページなどを参考にインストール完了してください。
cd (path to)/db-4.3.27/build_unix
../dist/configure
make
make install
sendmailを前もってインストールしておく
cd (path to)/sendmail-8.13.4
vi devtools/Site/site.config.m4
sh Build -c
sh Build install
libmilterをインストールしておく
cd (path to)/sendmail-8.13.4/libmilter
sh Build -c
sh Build install
※ここまでは他のページなどを参考にインストール完了してください。
いよいよmilter-limitのインストール
# cd (path to)/com/snert/src/lib
# ./configure
# make build
# cd ../milter-limit
# ./configure
# make build
# make install
# ./configure
# make build
# cd ../milter-limit
# ./configure
# make build
# make install
でインストール完了
次はsendmail.cfを作成する。
sendmail.mcに以下を追記する
dnl -------------------------------------------------------------------
dnl milter-limit.mc
dnl -------------------------------------------------------------------
dnl Example configuration to be added to sendmail.mc.
dnl
dnl Copyright 2004, 2006 by Anthony Howe. All rights reserved.
dnl
dnl $OpenBSD$
dnl
define(`_FFR_MILTER', `1')dnl
dnl -------------------------------------------------------------------
dnl Enable this for debug output from Sendmail.
dnl define(`confLOG_LEVEL', `14')dnl
dnl -------------------------------------------------------------------
dnl Enable this to see even more debug output.
dnl Defaults to confLOG_LEVEL.
dnl
dnl If Milter.LogLevel is greater-than:
dnl
dnl 0 Communication errors
dnl 8 Header & RCPT modification messages
dnl 9 Connect to info
dnl 10 Milter error return codes, abort messages
dnl 12 More return code info, connection/open errors
dnl 14 grey & rcpts info
dnl 17 Show headers & body sent to a milter.
dnl 18 Quit
dnl 21 Time a milter
dnl define(`confMILTER_LOG_LEVEL', 14)dnl
dnl -------------------------------------------------------------------
dnl The S= by default specifies a unix domain socket to be used between
dnl sendmail and the milter. It can also be an Internet domain socket.
dnl The accepted forms are:
dnl
dnl {unix|local}:/path/to/file A named pipe. (default)
dnl inet:port@{hostname|ip-address} An IPv4 socket.
dnl inet6:port@{hostname|ip-address} An IPv6 socket.
dnl
dnl Note that the F= says what to do with the message if the milter
dnl is not running.
dnl
dnl F=T Temporary fail connection if filter unavailable
dnl F=R Reject connection if filter unavailable
dnl
dnl If no F= specified and there is a problem with the milter, then
dnl the default is to continue normal handling, skipping the milter.
dnl
dnl Note that the T= specifies timeouts for communication. The
dnl following fields are defined:
dnl
dnl C Timeout for connecting to a filter. If set to zero (0),
dnl the system's connect() timeout will be used. Default: 5m
dnl S Timeout for sending information from the MTA to a
dnl filter. Default: 10s
dnl R Timeout for reading reply from the filter. Default: 10s
dnl E Overall timeout between sending end-of-message to filter
dnl and waiting for the final acknowledgment. Default: 5m
dnl
dnl So the Sendmail default values are equivalent to:
dnl
dnl T=C:5m;S=10s;R=10s;E:5m
dnl
INPUT_MAIL_FILTER(
`milter-limit',
`S=unix:/var/run/milter/milter-limit.socket, T=C:10s;S:10s;R:10s;E:10s'
)dnl
dnl -------------------------------------------------------------------
dnl End milter-limit.mc
dnl -------------------------------------------------------------------
dnl milter-limit.mc
dnl -------------------------------------------------------------------
dnl Example configuration to be added to sendmail.mc.
dnl
dnl Copyright 2004, 2006 by Anthony Howe. All rights reserved.
dnl
dnl $OpenBSD$
dnl
define(`_FFR_MILTER', `1')dnl
dnl -------------------------------------------------------------------
dnl Enable this for debug output from Sendmail.
dnl define(`confLOG_LEVEL', `14')dnl
dnl -------------------------------------------------------------------
dnl Enable this to see even more debug output.
dnl Defaults to confLOG_LEVEL.
dnl
dnl If Milter.LogLevel is greater-than:
dnl
dnl 0 Communication errors
dnl 8 Header & RCPT modification messages
dnl 9 Connect to info
dnl 10 Milter error return codes, abort messages
dnl 12 More return code info, connection/open errors
dnl 14 grey & rcpts info
dnl 17 Show headers & body sent to a milter.
dnl 18 Quit
dnl 21 Time a milter
dnl define(`confMILTER_LOG_LEVEL', 14)dnl
dnl -------------------------------------------------------------------
dnl The S= by default specifies a unix domain socket to be used between
dnl sendmail and the milter. It can also be an Internet domain socket.
dnl The accepted forms are:
dnl
dnl {unix|local}:/path/to/file A named pipe. (default)
dnl inet:port@{hostname|ip-address} An IPv4 socket.
dnl inet6:port@{hostname|ip-address} An IPv6 socket.
dnl
dnl Note that the F= says what to do with the message if the milter
dnl is not running.
dnl
dnl F=T Temporary fail connection if filter unavailable
dnl F=R Reject connection if filter unavailable
dnl
dnl If no F= specified and there is a problem with the milter, then
dnl the default is to continue normal handling, skipping the milter.
dnl
dnl Note that the T= specifies timeouts for communication. The
dnl following fields are defined:
dnl
dnl C Timeout for connecting to a filter. If set to zero (0),
dnl the system's connect() timeout will be used. Default: 5m
dnl S Timeout for sending information from the MTA to a
dnl filter. Default: 10s
dnl R Timeout for reading reply from the filter. Default: 10s
dnl E Overall timeout between sending end-of-message to filter
dnl and waiting for the final acknowledgment. Default: 5m
dnl
dnl So the Sendmail default values are equivalent to:
dnl
dnl T=C:5m;S=10s;R=10s;E:5m
dnl
INPUT_MAIL_FILTER(
`milter-limit',
`S=unix:/var/run/milter/milter-limit.socket, T=C:10s;S:10s;R:10s;E:10s'
)dnl
dnl -------------------------------------------------------------------
dnl End milter-limit.mc
dnl -------------------------------------------------------------------
以下のコマンドでsendmail.cfをつくり、cfを所定の場所に配置する。
sh Build sendmail.cf
sh Build install-cf
sh Build install-cf
ファイルの権限などが以下のようになっているか確認する。
/etc/mail/ root:smmsp 0750 drwxr-x---
/etc/mail/access.db root:smmsp 0640 -rw-r-----
/etc/mail/sendmail.cf root:smmsp 0640 -rw-r-----
/etc/mail/milter-limit.cf root:root 0644 -rw-r--r--
/var/run/milter/milter-limit.pid milter:milter 0644 -rw-r--r--
/var/run/milter/milter-limit.socket milter:milter 0644 srw-r--r--
/var/db/milter-limit milter:milter 0644 -rw-r--r-- (*BSD)
/var/cache/milter-limit milter:milter 0644 -rw-r--r-- (linux)
/usr/local/libexec/milter-limit root:milter 0550 -r-xr-x---
1秒に1通などという制限をかけて送信する場合には
# vi /etc/mail/access
に
milter-limit-To:hoge@example.com 1/1s
などのように記述し、
makemap -v hash /etc/mail/access.db < /etc/mail/access
として、DBを作成する。
※その後、milter-limitの再起動を忘れないように!
# /etc/init.d/milter-limit restart
また、1秒間隔で送信制限をしたいなどという時にはQueueRunnerの間隔の変更が必要
(QueueRunnerが動いたタイミングでキューがフラッシュされる)
# vi /etc/init.d/sendmail
QUEUE=1h
QUEUE=1h
の部分を
QUEUE=1s
などに変更する。
(1秒間隔でキューをフラッシュするとキューフォルダにあるメールすべてが再試行され、そのときにかなり大量のログを吐き出すので、注意!)
また、起動スクリプトの中で
/etc/sysconfig/sendmail
の中の設定が優先になっているので、
# vi /etc/sysconfig/sendmail
QUEUE=1s
と書き換えて完了。
COMMENTS