月曜日, 9月 06, 2010

Postfix 特定パターンの宛先を正規表現でまとめて処理

2008/02/04perlfreak.vox.comより転載)

Postfix の main.cf の alias_maps の行を

alias_maps = hash:/etc/postfix/aliases, regexp:/etc/postfix/alias.reg

のように正規表現用のファイルの記述を追加したものに変更する。
alias.reg を作成し、例えばつぎのように記述する。

/^test[0-9]{2}(@.*)?$/ |"/usr/local/bin/hoge.pl"

最後にPostfixを再起動する。
これで、例えばこのメールサーバのドメインが example.com だとして、

test00@example.com
test01@example.com
test02@example.com

test99@example.com

これらにメールを送信すると、hoge.pl が処理を行う。

0 件のコメント: