If you run your own IMAP server or if you use Thunderbird, you may have run into the problem where there are just too many emails in your folder and you need to delete them.
It seems that at a certain threshold of emails, trying to delete your email through any normal IMAP client is just impossible. I first had this happen when I was mail bombed with about 3000 emails. For some reason, Thunderbird just couldn't handle deleting them. I would select all the messages in my inbox and hit delete. Then it would sit there for hours just spinning.
My first thought was that this was a server problem. To troublshoot it, I created a groovy script to run through my inbox and delete the messages. It worked and actually finished it in 5 minutes! So it appears there is definitely a problem with Thunderbird and other clients.
Just a few days ago I had the same problem again. Only this was on a much larger scale. Due to a configuration problem in my postfix mail server, I had over 190,000 emails sent to my inbox in a matter of 36 hours. Yikes!
I ran the script and it took about 12 hours in total to finish it. Without it, I would just have had to delete the entire account and loose all of my email. And manually going through and deleting all that email would be impossible for all practical purposes.
The script was more than just a straight forward connect and delete. Committing the changes on 10,000 emails usually kills your IMAP server. To get around this, it processes a few then disconnects and reconnects. This is slower, but works.
Attached is the script if you run into this problem.
| Attachment | Size |
|---|---|
| imap-cleanup.groovy | 2.29 KB |