My mail queue has grown to over 70000 emails. Is there any way I can do a filtered delete to get rid of outgoing emails from the MAILER-DAEMON@ without losing any potentially valuable emails?

link|improve this question
More details as this isn't enough information... – Joey Sep 7 '09 at 20:03
It's not relevant to stackoverflow, either. – skaffman Sep 7 '09 at 20:04
You need to say what OS and Mail Transfer Agent you're using. Windows+Exchange? Linux and Sendmail? Exim? Postfix? – David Pashley Sep 7 '09 at 20:08
feedback

migrated from stackoverflow.com Sep 7 '09 at 20:05

This question came from our site for professional and enthusiast programmers.

1 Answer

you didn't mention which email server you use, assuming you use postfix

mailq >q.txt

grep MAILER-DAEMON q.txt | sed 's/ .*//' | sed 's/^/postsuper -h /' > md.sh

sh md.sh

if you want you can put everthing into one line, but if you have a lot of mails in your queue, this will take some time and putting the list into a file first saves you running the command again if something goes wrong.

with postsuper -h you will put the mails into a hold queue so you will not loose them either, you can delete the mails later.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown