Deleting IMAP mail from shell script

Wil Cooley wcooley at
Thu May 12 19:30:18 EDT 2005

On Thu, 2005-05-12 at 16:35 -0600, Sun Advocate Webmaster wrote:
> I have a simple question concerning mail deletion in Cyrus mailboxes. I 
> have spamassassin set up, with two mailboxes "spam at" and 
> "notspam at". A shell script runs periodicly and parses these 
> messages (sa-learn compiles training data from the messages). After that 
> parsing is done, it needs to empty the mailboxes.
> I was going to add a "rm" command, but I'm thinking that will cause data 
> corruption with cyrus.
> Is there a better way to do this?

Fiddling directly with the Cyrus mail spool is a bad thing.  Here's a
script I wrote to do what you want, except for the 'notspam' part:

You'll also need the from the parent directory.

Wil Cooley                                 wcooley at
Naked Ape Consulting              
* * * * Linux, UNIX, Networking and Security Solutions * * * *
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url :

More information about the Info-cyrus mailing list