mkdir ~/.muttcache
echo "set header_cache=~/.muttcache/" >> ~/.muttrc

As easy as that. Why didn't I do this earlier?

Well, I decided that it sucks and turned it off. The indexes take up an incredible amount of disk space and it actually seems to make mailbox accesses much slower as it seems to rebuild it from scratch whenever a change is made, and naturally this is slower than just loading the whole thing, especially after I moved mutt to a faster machine.

Since that was a let-down, here's a better tip:

folder-hook SPAM 'set sort=reverse-date-received'

The date on spam is occasionally set way in the future, so my normal sort-by-date means that the same old spam always appears at the top of the list and I'm less inclined to actually look at new messages. This sorts my spam folder more sensibly and is, for now, the next best thing to a 'sort with unread first'.

While I'm on the topic of spam, here's what I do to control mine.

I used sendmail with SpamAssassin and spamass-milter, the latter configured using Debian's instructions. I was using procmail to /dev/null very spammy (score 15+) messages and since I'm blissfully unaware of any false positives, I configured spamass-milter to reject these at SMTP time in /etc/default/spamass-milter. I even cranked down the threshold as well! Considering I don't bother looking at spam too closely anymore, I reckon it's safe to lower the threshold to anything reasonable when you're rejecting things rather than binning them, though it's hard to know whether you should just bin them and prevent back-scatter when an innocent relay is involved. Actually, binning them is probably better but there's something satisfying about rejecting mail and if someone does send a legitimate but spammy-sounding email, they'll hear about the rejection this way.

OPTIONS="-r 12"

This also has the classy bonus that I no longer have to set per-user procmail spam dropping rules.

Since I mostly use mutt, it's easy to classify messages as soon as I find them. In .muttrc:

macro pager S "<enter-command>unset wait_key\n<pipe-entry>sa-learn --single --spam \n<enter-command>set wait_key\n<save-message>=.SPAM\n"
macro index S "<enter-command>unset wait_key\n<pipe-entry>sa-learn --single --spam \n<enter-command>set wait_key\n<save-message>=.SPAM\n"
macro pager H "<enter-command>unset wait_key\n<pipe-entry>sa-learn --single --ha

m \n<enter-command>set wait_key\n"macro index H "<enter-command>unset wait_key\n<pipe-entry>sa-learn –single –ham \n<enter-command>set wait_key\n"

It would be nicer if the command would pipe all messages to one instance of sa-learn, which would make this a bit faster. It's probably quite easy, but I just stole this from elsewhere and haven't been too bothered about it.

To automatically train SpamAssassin with ham, I set up a cron job that looks in cur folders (ie, things I've seen)

0 2 * * * find /home/joel/Maildir/.saved/cur/ /home/joel/Maildir/.uni/cur/ -type f -mtime -2 -print | xargs sa-learn --ham  > /dev/null

And another that classifies things as spam if I've seen them and didn't move them to non-spam. This is done because it won't auto-learn off messages it thinks are spammy but doesn't know for sure.

5 2 * * * find /home/joel/Maildir/.SPAM/cur/ -type f -mtime -2 -print | xargs sa-learn --spam > /dev/null

The other thing I like doing with mutt is using Mairix for full-text indexing. Dovecot can also do full-text indexing, but I don't use mutt with IMAP.