How I got my Inbox back.

Like many of us here, I have been reading “Time Management for System Administrators” by Thomas Limoncelli. A lot of what is in the book is common sense, things that you look at and go, “Oh! Hey, right on!” or “Why did I not think of that in that way before?”.

Then I got to Chapter 10, “Email Management”.
Wow.

Technical info:
I use “mutt”:http://www.mutt.org for reading email.
My email is on an IMAP server.

I have always been one of those people that kept every single email that was ever sent to me. All of them. If you have sent me an email, chances are I still have it. Well I did anyway, then I got to Chapter 10.

One reason I always kept any email sent to me was because in the past I have had to go back and use it as a “Cover my ass” when someone tried to change history. So I was loath to delete stuff.

My fix for this was to instead of deleting mail, send it to the trash. So I added this macro to my .muttrc.


macro index d "s=Trashn" "move to trash"
macro pager d "s=Trashn" "move to trash"

To keep the Trash folder from growing to an unmanageable size, I use a program called “IMAPfilter”:http://imapfilter.hellug.gr. IMAPfilter can be setup to search a mailbox for any mail older than 30 days and then delete it. It can also search the body, headers, to, from, subject, etc. It really is pretty slick. For those of us using “Debian”:http://www.debian.org it is just a an “apt-get install imapfilter” away.

Another thing that happens to System Administrators is that they get status emails, bounce messages, etc. Things that we typically do not have to do anything with, but we don’t want to necessarily delete them out of hand. So, I setup some filters to move mail like that into the “hold” folder. That way if I need to go back and check postmaster undeliverable emails, I can. This folder is also cleaned out of things older than 30 days.

So based on Tom’s recommendations, this is my setup now:
INBOX
– Spam
– NewSpam
– NotSpam
– save
– hold
– Trash

The NewSpam and NotSpam folders are picked up by a script to feed to SpamAssassin as appropriate. The Spam folder gets the same 30 day treatment that hold and Trash do, it does not take long to get 13000+ emails into that folder.

Here is an IMAPfilter config.lua that is close to what I have:

-- accounts
account_work = {
    server = 'SERVER NAME',
    username = 'USERNAME',
    password = 'PASSWORD',
}

-- filters
filter_30_days = {
    'before ' .. date_before(30),
}

filter_postmaster = {
    'subject "Postmaster notify: see transcript for details"',
    'to "postmaster"',
}

filter_to_www = {
    'to "www-data"',
}

filter_aide = {
    'from "root"',
    'body "AIDE detected no changes"',
    'subject "Daily AIDE report for"',
}

filter_apache = {
    'body "/usr/sbin/apachectl graceful: httpd gracefully restarted"',
    'from "Cron Daemon"',
}

function forever()

-- delete spam older than 30 days
results = match(account_work, 'Spam', filter_30_days)
delete(account_work, 'Spam', results)
results = {} -- clear our results
--
--

-- delete trash older than 30 days
results = match(account_work, 'Trash', filter_30_days)
delete(account_work, 'Trash', results)
results = {} -- clear our results
--
--

-- move some mail to the hold folder
-- delete anything older than 30 days from the hold folder
results = match(account_work, 'INBOX', filter_postmaster)
move(account_work, 'INBOX', account_work, 'hold', results)
results = {} -- clear our results

results = match(account_work, 'INBOX', filter_to_www)
move(account_work, 'INBOX', account_work, 'hold', results)
results = {} -- clear our results

results = match(account_work, 'INBOX', filter_aide)
move(account_work, 'INBOX', account_work, 'hold', results)
results = {} -- clear our results

results = match(account_work, 'INBOX', filter_apache)
move(account_work, 'INBOX', account_work, 'hold', results)
results = {} -- clear our results

results = match(account_work, 'hold', filter_30_days)
delete(account_work, 'hold', results)
results = {} -- clear our results

end
daemon_mode(60,forever)