# IMAPCleanse

**URL:** <https://www.ruby-forum.com/t/imapcleanse/90213>\
**Category:** Ruby\
**Created:** [March 29, 2006, 9:22pm UTC](https://www.ruby-forum.com/t/imapcleanse/90213 "2006-03-29T21:22:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![miracleofmagick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71c47a/32.png) [@miracleofmagick](https://www.ruby-forum.com/u/miracleofmagick)\
**Post date:** [March 29, 2006, 9:22pm UTC](https://www.ruby-forum.com/t/imapcleanse/90213/1 "2006-03-29T21:22:35Z")

</div>

= IMAPCleanse

Rubyforge Project:

[http://rubyforge.org/projects/seattlerb/](http://rubyforge.org/projects/seattlerb/)

Documentation:

[http://seattlerb.rubyforge.org/IMAPCleanse/](http://seattlerb.rubyforge.org/IMAPCleanse/)

== About

IMAPCleanse removes old, read, unflagged messages from your IMAP  
mailboxes.

== Why?

I’m lazy. I don’t delete read messages from my mailboxes because I  
like to  
have context when reading threads. Since I’m lazy my more-trafficed  
mailboxes  
can end up with tens of thousands of read messages. Deleting this many  
messages with Mail.app is time consuming and boring.

So I wrote IMAPCleanse to clean out my old mailboxes for me. If I  
want to keep  
a message around for forever I’ll just flag it and IMAPCleanse won’t  
touch it.

== Installing IMAPCleanse

Just install the gem:

$ sudo gem install IMAPCleanse

== Using IMAPCleanse

In short:

imap\_cleanse -H [mail.example.com](http://mail.example.com) -p mypassword -b Lists/FreeBSD/  
current,Lists/Ruby -a 30

The help for IMAPCleanse should be sufficiently verbose, but here’s a  
couple of  
tips:

=== --noop and --verbose

The --noop flag tells IMAPCleanse not to delete anything. When  
combined with  
the --verbose flag you can see how many messages IMAPCleanse would  
have deleted  
from which mailboxes.

$ ruby -Ilib bin/imap\_cleanse -nv

# Connected to [mail.example.com:993](http://mail.example.com:993)

# Logged in as drbrain

# Cleansing read, unflagged messages older than 26-Feb-2006 17:04 PST

# Found 23 mailboxes to cleanse:

# mail/Lists/FreeBSD/current

[…]

# mail/Lists/Ruby/ZineBoard

# Selected mail/Lists/FreeBSD/current

# Scanning for messages

# Found 0 messages

[…]

# Selected mail/Lists/Ruby/ZineBoard

# Scanning for messages

# Found 0 messages

# Done. Found 0 messages in 23 mailboxes

(Since I just ran IMAPCleanse it didn’t have anything to do.)

=== ~/.imap\_cleanse

The ~/.imap\_cleanse file can hold your password and other options so  
you don’t  
have to type them in on the command line every time. The format is  
simple,  
just the options file name followed by ‘=’ followed by the argument.

No whitespace is stripped from options, so be sure to do that  
yourself. Mine  
looks something like this:

[Host=mail.example.com](http://Host=mail.example.com)  
SSL=true  
Username=drbrain  
Boxes=Lists/FreeBSD/current,Lists/FreeBSD/performance,Lists/  
FreeBSD/Soekris,Lists/FreeBSD/stable,Lists/Ruby  
Age=30  
Password=my password

–  
Eric H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)
