An Arcane Question

I couldn’t sleep, so I figured I’d work on purging some old e-mail from my Inbox.

I wound up with something like 30,000 messages in my Trash folder on our Exchange server. When I went to empty the folder, Thunderbird seemed to want to download each message first. Argh!

I decided to use Ruby’s Net::IMAP, but sending an expunge command to the trash does nothing. The folder still had 30,000 messages. I remembered some weirdness where things weren’t actually getting deleted off the server until I disconnected, so I gave that a try, too. I reconnected and they’re still there.

Anyone have any thoughts? I don’t know where the problem lies. Is it an IMAP thing in general that you can’t “expunge” the trash folder, but must do something special (like iteratively delete each message)? An Exchange oddity? Or a limitation of Net::IMAP?

Toying with Net::IMAP has got me thinking that IMAP is a pretty weird protocol, by the way. Who knew that searching was done server-side, for example? I suppose it kind of makes sense (saves bandwidth from keeping the client from having to get each message), but it also seems like a single person with a big inbox could search and bring the whole server to its knees. Shows why your mailservers need to be beefy machines, I guess. A lot of the simple tasks you perform in a mail client are more complicated than I’d have thought, too. You don’t delete mail, for example. You modify the message and set a “DELETED” attribute. And then you expunge the mailbox.

Some time when it’s not 3am, I think I want to brush up the Net::IMAP code fragments I have and whip up something that will walk through some of the folders I have and delete anything older than 14 days. A horrible idea on some folders, but on automated status e-mails and error e-mails, it’s more than generous. I probably have something like 500-1000 e-mails sent to me by scripts that need regular deletion. I was surprised to find that there’s no Thunderbird extension for this, but I think I may prefer to have it be a cron job that runs overnight, since mail clients can lag out when tens of thousands of messages disappear from folders.

Leave a Reply

Your email address will not be published. Required fields are marked *