Delete all email with a specific subjet or sender or header content

davide

New Email
Hello,
have you a tool to delete from a mailbox all the message with a specific subject, sender or also email header content.

Using regular expression.

I need this to clean mailboxes that has been hackend and that containt thousands on Undelivery emails or other spammer emails.

Thank you
 

rfs9999

IMAP Tools
Yes. you can do this with imapfilter.pl (http://www.emailquestions.com/imap-tools/8079-imap-filter.html).

imapfilter can be used to move messages that match any of a set of rules from one mailbox to another (eg the Trash).

For example:

rule Subject "Project completed" INBOX Trash
rule Subject "requires Approval" INBOX Trash
rule From "David Smith" INBOX Trash

Regular expressions are supported. For example:

Subject "\[imap-tools\]\s*Fixed bug" INBOX Trash

Here's the output from a typical run.

Checking for filter matches

msgnum 12 in INBOX matches rule: 'Subject "requires approval" INBOX
Trash'
msgnum 13 in INBOX matches rule: 'Subject "requires approval" INBOX
Trash'
msgnum 14 in INBOX matches rule: 'Subject "requires approval" INBOX
Trash'
msgnum 15 in INBOX matches rule: 'Subject "requires approval" INBOX
Trash'
msgnum 18 in INBOX matches rule: 'Subject "requires approval" INBOX
Trash'
msgnum 21 in INBOX matches rule: 'Subject "requires approval" INBOX
Trash'
msgnum 22 in INBOX matches rule: 'Subject "requires approval" INBOX
Trash'
Moved 7 message(s) from INBOX to Trash

msgnum 12 in INBOX matches rule: 'From "David Smith" INBOX Trash'
msgnum 13 in INBOX matches rule: 'From "David Smith" INBOX Trash'
msgnum 14 in INBOX matches rule: 'From "David Smith" INBOX Trash'
msgnum 15 in INBOX matches rule: 'From "David Smith" INBOX Trash'
msgnum 18 in INBOX matches rule: 'From "David Smith" INBOX Trash'
msgnum 19 in INBOX matches rule: 'From "David Smith" INBOX Trash'
msgnum 20 in INBOX matches rule: 'From "David Smith" INBOX Trash'
Moved 7 message(s) from INBOX to Trash

msgnum 125 in INBOX matches rule: 'Subject "Project completed" INBOX
Trash'
Moved 1 message(s) from INBOX to Trash

15 total messages moved
Done

Some notes:

1.) imapfilter can operate on a single user or on multiple users by
passing it a list of users.

2.) imapfilter supports admin mode, meaning you don't have to supply
the passwords for individual users, just the administrator's name &
password (assuming your server supports admin mode).

3.) Rules can be applied to a single mailbox (INBOX for example) or to
all of the user's mailboxes (*).

4.) For more information please see IMAP Tools.

-Rick

--
Rick Sanders
rfs9999@earthlink.net
IMAP Tools IMAP Tools
 
Top