MyDoom in mail queue

Is there someone out there that has a script for cleaning up the mail queue after viruses such as MyDoom?

what do you mean clean up the mail queue?

In the mail queue (mailq && /var/spool/mqueue) we have a bunch of MyDoom virus emails waiting to be delivered to domains and email addresses that does not exist.

I would like to remove them since they should not be sent because they are viruses.

I have a start of a script:
grep -f ./patterns.txt /var/spool/mqueue/dfi* | awk -F: '{print $1}' | tr -d '/var/spool/mqueue/dfi' | awk -F: '{print "rm -
f /var/spool/mqueue/qfi"$1" /var/spool/mqueue/dfi"$1}'>/home/pjohansson/mqueue/filtered/run_this
chmod +x ./run_this

With the accompaning file:
cat patterns.txt
filename="message.zip"
filename="body.zip"
filename="data.zip"
filename="text.scr"
filename="text.zip"
filename="data.pif"
filename="readme.zip"
filename="file.zip"
filename="readme.scr"

but I am getting
rm: lstat 'filename' cannot find file or something like this.

The following line is messing with the file name so that it isn't correct anylonger.
tr -d '/var/spool/mqueue/dfi'

It takes "/var/spool/mqueue/dfi19KKak8007138" and returns "19KKk8007138". So somehow it removes the lower case a. What I want it to do is to remove the path up to and including the dfi in the filename.

Any ideas why it removes the a?
Any suggestions on what else to use? sed?

Not sure what the pattern is here ... do you have multiple files that start with dfi but are located in different directories?

The solution could be to use

... | sed 's=/var/spool/mqueue/dfi==' | ...

but usually you want the answer to be able to fit a variety of different file name patterns, and not just ones that begin with dfi and are located in /var/spool/mqueue...

Thanks!

sed worked for me.