Praji’s Weblog

Welcome to praji’s world

Script to remove Junk mails from exim mail queue

with one comment

Page 72

Script to remove Junk mails from exim mail queue

!/usr/bin/perl -w

#Removes junk mails including bounce backs from the mail queue
# Usage perl killmail &> <filename>

system “/etc/init.d/chkservd stop”;
system “/etc/init.d/exim stop”;

open FD, “exim -bpru |”;

while (<FD>) {
# Remove mails older than a day, ie >= 1d
if (/^[\s]*?[\d]+[d][\s]+[\d.]+\w?[\s]+([\w\d-]+).*/) {
print “$&\n”;
system “exim -Mrm $1”;
}
# Remove mails older than 9 hours
if (/^[\s]*?\d{2,}[h][\s]+[\d.]+\w?[\s]+([\w\d-]+).*/) {
print “$&\n”;
system “exim -Mrm $1”;
}
# Remove bounce backs, if any
if (/^[\s]*?\d+[mhd][\s]+[\d.]+\w?[\s]+([\w\d-]+)\s+<>/) {
print “$&\n”;
system “exim -Mrm $1”;
}
}

system “/etc/init.d/chkservd start”;

Written by praji

April 13, 2008 at 2:36 am

One Response

Subscribe to comments with RSS.

  1. Hi! I was surfing and found your blog post… nice! I love your blog. 🙂 Cheers! Sandra. R.

    sandrar

    September 10, 2009 at 9:45 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: