Mutt: Mailbox power tool

Milestone_1_6_–_Mutt

“All mail clients suck. This one just sucks less.”

Mutt is a commandline mail client that’s been in use and been actively developed for about two decades. It’s considered by many to be the most powerful mail client available, particularly for handling large volumes of email. It’s weaknesses include poor rich text handling and desktop integration for attachment handling – which led to it losing market share to GUI mail clients.
But it’s still a very powerful client. And, particularly if you use IMAP, you don’t have to use a single mail client for everything. If you find yourself needing to do complex bulk operations on a mailbox, and your regular GUI client isn’t up to it, consider using Mutt.
I found myself with 116,000 messages in my inbox. (I’ve heard of inbox zero, but it doesn’t really suit my workflow). Mail.app starts to misbehave with large mailboxes – losing track of messages – and it can’t handle moving tens of thousands of messages from an inbox to an archive mailbox without crashing. Nor could several other GUI mail clients I had handy.
Time to pull out mutt to perform some mailbox surgery.
I’m on OS X, and have homebrew installed, so installing mutt was as simple as “brew install mutt“. Any unix system will have it available as a standard package (if it’s not already installed), and there’s some support for installing it on Windows.
You can configure it to talk to your IMAP server like this, if your server uses TLS. Copy this into “~/.muttrc

set spoolfile="imaps://steve:passwd@mx.wordtothewise.com/INBOX"
set folder="imaps://steve@mx.wordtothewise.com/"
set header_cache="~/.cache/mutt/headers"

You’ll need to set your username, password and the hostname of your IMAP server in the first two lines. The third line just configures mutt to cache message metadata locally – it’s not essential, but it makes switching between large folders somewhat faster.
Then run “mutt” and wait for it to connect to your IMAP server and open your inbox. Mutt is controlled almost entirely with single keypresses. “?” will show help. Page-up, page-down will scroll through text or mailboxes. The top line of the screen will show a few useful keys, including how to exit out of the current page.
You can list available mailboxes by typing “c?“. From there you can use the arrow keys and return to select a mailbox and open it, or you can use “C” to create a new (IMAP) mailbox.
When you’re in a mailbox you can scroll through it with the arrow keys, use “/” to search or type a number to go to that message in the mailbox.
So far, nothing particularly different to any other mail client. Where things get interesting is when you start using tagging to perform bulk operations.
You can tag or untag an individual message with “t“. Tagged messages will be shown with a “*“. Much more powerful is the tag pattern command, “T“. When you hit “T” mutt will give you a prompt: “Tag messages matching:”. From that prompt you can use any of the patterns shown in the mutt manual to tag multiple messages.
I wanted to select all my mail from 2012 and earlier, to move it to an archive mailbox, so I entered:

Tag messages matching: ~d -31/12/2012

That tagged a few tens of thousands of messages.
Then I used the “tag-prefix” command, followed by the “save” command to save (move) all the tagged messages to a new mailbox. “;s?” – the semicolon is the tag-prefix command, meaning “do the next thing to all the tagged messages”. “s” is “save”, meaning copy a message to a new location then delete the original (most mail clients describe this as “move”, but when in muttland …). The “?” opens a list of mailboxes to choose from.
I want to move everything to a new mailbox, so I type “C” and give it the name “archive2012” to create a new mailbox. Then I move the cursor to that new mailbox and hit return to start the “save” operation.
A few seconds later and all the messages have been moved. They’re still visible in the inbox, but marked with a “D” flag to show they’ve been deleted. I can use the purge command, “$” to completely remove them right away, or I’ll be prompted to purge them when I leave the mailbox.
Throughout this process Mutt hasn’t downloaded any of the messages to local disk, just a cached copy of the message headers. And all the copying of messages was done by moving them directly on the IMAP server, not by downloading and reuploading them – so everything was fast, or as fast as the IMAP server can be, and it didn’t use much local disk space.
It takes a little effort to learn how mutt works, but it’s an incredibly powerful tool for manipulating mailboxes, particularly via IMAP. Browse through the patterns section of the mutt manual to get some idea of it’s power.
 

Related Posts

A new way of reading email

Fastcompany reports that AOL has a new webmail client “Alto” that changes how email is read and received.

Read More

Confusing the engineers

We went camping last weekend with a bunch of friends. Had a great time relaxing on the banks of the Tuolumne River, eating way too much and visiting.
On Saturday I was wearing a somewhat geeky t-shirt. It said 554: abort mission. (Thank you MessageSystems). At some point on Saturday every engineer came up to me, read my shirt and then looked at me and said “That’s not HTTP.”
That lead to various discussions about how their junior engineers don’t actually know SMTP at all. Why? Because the SMTP libraries just work. Apparently the HTTP libraries aren’t that great, so folks have to learn more about HTTP to troubleshoot and use them.
I’m sure there’s a joke in there somewhere: A Kindle engineer, an Android engineer and a robot engineer walk into a campsite…
EmailFilters_boxes_forblogIt did leave me thinking, though, about how it’s not that easy to run your own mail server these days. Gone are the days when running your own server was cost effective and easy. These days, there is just too much spam coming in. Crafting filters is a skilled job. It’s not that hard to run good filters. But to run good filters takes time to do well.
There are also a lot of challenges to sending mail. One of the discussions I had at the campsite was how hard it was to configure outbound mail. The engineer was helping a friend set up a website and trying to get the website to send notifications to the friend. But without setting up authentication the mail kept silently failing.
Of course, we do run our own mail server. But it’s our job and, in many ways, it keeps us honest. We don’t run many filters meaning we see what spammers are doing and can use our own experiences to better understand what commercial filters are dealing with.
For most people, though, I really think using a service is the right solution. Find one with filters that meet your needs and just pay them to deal with the headache.
 

Read More