We need an Python Command Line Application which connects to an IMAP4 server and scans all messages (in all subfolders) of a certain account. If the messages are older than a certain date and have Attatchments bigger than a certain size
the attatchmens should be extracted from the Message.
In addition there should be an option to remove the attatchment from the message (but keep the message) on the server (to save space on the server).
Output Should be put in CouchDB (see http://code.google.com/p/couchdb-python/#) where you should put To:, From:, Date:, Subject, In-Reply-to, References and Message-Id in the document. The Attatchment should be added as couchdb Attatchment conserving the mime type and file name.
Command line invokation might look like this:
remove-attachments
--server=myserver.example.com # IMAP hostname
--user=username # IMAP user
--password=pass # IMAP password
--couchdb=http://localhost:5984/maildb # save to couchdb running here
--mindate=2009-03-01 # only check messages send befor this date
--minsize=1500 # only check messages bigger than 1500 KB
--remove # remove attatchments
If an Attatchment is removed instead of it there should be put a note in the message that an attatchment has been removed.
Since we will have extremely big (> 50GB) Mail Folders the tool must be able be run several times on the same account without generation duplicates in CouchDB.