作为Postfix MTA的管理员,维护队列是家常便饭,但如何能够方便的按自己的意愿控制对列呢?这需要一点perl和regexp的知识。
以下提供一个perl的小程序,由一个国外朋友写的,通过命令行传递正则表达式,匹配的邮件将被删除。
queue_mgr.pl
$REGEXP = shift || die "no email-adress given (regexp-style, e.g. bl.*\@yahoo.com)!";@data = qx-p
>;
for (@data) {
if (/^(\w+)\*?\
s/) { $queue_id = $1; }
if($queue_id) {
if (/$REGEXP/i) { $Q{$queue_id} = 1; $queue_id = ""; } } }
open(POSTSUPER,"| postsuper
-d -") ||
die "couldn't
open postsuper" ;
foreach (
keys %Q) {
print POSTSUPER "$_\n"; };
close(POSTSUPER);