public
Description: Miscellaneous toys and scripts
Homepage: http://blog.bleything.net
Clone URL: git://github.com/bleything/miscellany.git
miscellany / mailfixer
name age message
..
file LICENSE Loading commit data...
file README
file analyzer.rb
file finder.rb
mailfixer/README
========================================================================
mailfixer
Copyright 2008 Ben Bleything <ben@bleything.net>
Provided under the BSD license.
========================================================================

mailfixer is meant to analyze the contents of a Maildir to give you some
idea of exactly what the hell all those thousands of messages are.  I
originally wrote it because I'd been running with a catchall address for
9 years and it was time to delete all that mail.

It's pretty easy to use... first, run finder:

  ./finder.rb /path/to/your/maildir

That'll look at your disk, find a bunch of messages, and stick them in
your database.  It'll also remove messages that you've since deleted.

Next, run the analyzer:

  ./analyzer.rb

This does a couple of things:

 1) loads the message into a TMail mail object for easy header
    extraction
 2) puts the to, cc, delivered-to, and x-apparently-to headers in the
    database
 3) builds a mapping of address <-> header membership in the edges 
    table.  This lets you (for instance) determine that an address is
    junk and delete ever piece of mail sent to that address.

IMPORTANT NOTE!  There are places in the code that are specific to
my email addresses... you'll probably want to search through for
'bleything.net' and replace it with something that makes sense for you.
You probably want to read over the rest of the code too... there's not
that much of it.