fml のエラーメール解析プログラムを使う
メルマガを発行していてエラーを処理する必要があり、
バウンスメールの解析について調べていた。
http://www.fml.org/software/fml8/Documentation/ja/tutorial/error.internal.html
を見つけたので、試してみることにした。
ftp://ftp.fml.org/pub/fml8/fml-7.98.12-20060625.tar.gz
をダウンロードして中身を見ると fml/lib/Mail ディレクトリ以下にバウンスメールを解析するプログラムがあった。
あらかじめ以下のパッケージをインストールしておく。
$ sudo aptitude libunicode-japanese-perl libjcode-pm-perl libmailtools-perl
サンプルのプログラム: test.pl
use Mail::Message; my $msg = Mail::Message->parse( { fd => \*STDIN } ); use Mail::Bounce; my $bouncer = new Mail::Bounce; $bouncer->analyze( $msg ); # show results for my $a ( $bouncer->address_list ) { print "address: $a\n"; print " status: "; print $bouncer->status( $a ); print "\n"; print " reason: "; print $bouncer->reason( $a ); print "\n"; print "\n"; }
実際にバウンスメールを食わせる。
$ cat mail.txt | perl test.pl address: hoge@example.com status: 5.5.0 reason: smtp;550 Requested action not taken: mailbox unavailable
結構頑張っているけどまだまだな感じがした。