2008-12-13

Mairix and Mutt for Mail

After a long time of using webmail and things, I've finally gotten around to hosting my mail locally on my computer.

Keeping with the 'search not sort' philosophy of mail, I have set up a system where when I get email (using 'getmail' to download it via pop from my email hosting) I deliver the email to two places. One is an archive (named for the day it was received on) and the other is an Inbox.

When I read email in the inbox, I delete it. The archive is always there.

I have a mairixrc configured to index all my archive. Unfortunately the globbing for mairix doesn't seem to work for subdirectories, so I have all my archives in yyyymmdd named folders instead of yyyy/mm/dd folders. This way I can say maildir=Maildir/Archive/*.

Now that I have my email sorted like this, and mairix is indexing it (on a cronjob), I can search it. I wrote a little script to search my email. The idea is that I can select some text and click a button on my toolbar, or I can hit a button my toolbar and enter some text into a search prompt, then mutt will spawn pointed at a folder containing my search results.

Here is the one that prompts for input:
#!/bin/sh

searchdir=/var/tmp/searchresult-$$
selection=$(Xdialog --inputbox "Search For?" 18 45 2>&1)
# exit if Xdialog had a nonzero exit.
[ $? -ne 0 ] && exit "Okay, nevermind"

echo Searching for $selection
mkdir -p $searchdir
mairix -o $searchdir "$selection"
mutt -f $searchdir
rm -rf $searchdir


The one that uses the xclipboard just does selection=$(xclip -o) instead of the Xdialog dance.

1 comment:

massysett said...

The bit about copying the incomings to an inbox and an archive and just deleting from the inbox is awesome! I was thinking of using mairix but puzzled over how to deleet from the inbox, seeing as mairix gives you a pile of symlinks.