How To Use The Fast And Powerful Mutt Email Client With Gmail

Command-line tool mutt has a well-deserved reputation as a powerhouse of an email client. It's fast, flexible and, best of all, surprisingly easy to use. Unfortunately getting the thing up and running can be, put mildly, a bit of a chore.

If you've been tempted by mutt but put off by its complex array of options, the following basic setup will give you a chance to try it out on your Gmail account with a minimum of setup. So fire up your terminal and let's get started.

Installing mutt

To install mutt on Ubuntu:

sudo apt-get install mutt

To install mutt on OS X, you can use MacPorts:

sudo port -vc install mutt-devel +gnuregex +gpgme +headercache +imap +sasl +smtp +ssl +tokyocabinet

Or Homebrew:

brew install mutt

Next, create the directories mutt needs to cache message headers and bodies and store certificates, by pasting the following commands:

mkdir -p ~/.mutt/cache/headers mkdir ~/.mutt/cache/bodies touch ~/.mutt/certificates

Now pick one of the configuration files below, save it in your home directory and rename it to .muttrc:

(Due to a trademark dispute, we British Gmail users have a slightly different setup.)

Open up the ~/.muttrc file in your favourite text editor, add your name, Gmail address and password — everything you'll need to alter is in ALL CAPS — and save the file. (Ed note: Saving passwords in plain text is a nightmare for the tin-foil hat crowd, so if you'd rather not, just leave the password fields blank and mutt will prompt you for the passwords when they're necessary.)

Read, Reply to and Send Email from mutt

Now you're ready to read, reply to and send email from mutt: Run it from the command line by simply typing mutt. The first time you do this, you'll be prompted to accept two SSL certificates from Google; press 'a' to always accept these certificates. You should now be greeted by your Gmail inbox (if you didn't save your passwords in the .muttrc file above, you'll be prompted for that first):

mutt is controlled from the keyboard and helpfully displays a context-aware list of shortcuts at the top of every window.

The following shortcuts for navigating and processing mail should be familiar from Gmail's web interface:

  • j to move down.
  • k to move up.
  • d to delete a message
  • y to archive one
  • gi to view your Inbox
  • ga to view All Mail
  • gd to view Drafts
  • gs to view Starred messages

And here are a few more that are particular to mutt:

  • t will mark a message
  • s will save one, or more
  • c lets you change to a different folder
  • / lets you search the current folder

To view messages outside your inbox, type c and either type ? to view a list of all your tags and folders, or prepend your tag with an equals sign. So, to view messages tagged 'work', you'd type c, then =work, then hit Return.

Similarly, to save a message to the 'work' folder — the equivalent of labelling in Gmail — type s, then =work, then hit Return. If you've used t to mark a bunch of messages, then saving will apply to all of them.

You'll notice that, for some of the above commands, mutt won't do anything right away, instead marking messages for later processing. Once you're sure you've made all the changes you want to, e.g. deleted the right message, hit the $ key and mutt will apply all your changes to your Gmail account.

Sending mail with mutt

Ready to send your first message with mutt? The basics look like this:

  • Type m (or r if you're replying to a mail)
  • Enter the recipients email address; hit Return
  • Enter a subject; hit Return
  • Write your message.
  • Save it.
  • Type y, and your message will be sent.

All done? Type q to quit mutt.

We've really just scratched the service, so if you've spent much time with mutt in the past, let's hear your favourite tips and features in the comments.

Jack Mottram is a writer and technology lover. You can find more of his writing at One Thing Well, a weblog about simple, useful software.


Comments

    ...or alternatively, use a graphical email client like Thunderbird, Apple Mail or KMail to name a few..

      Graphics? Graphics are for people with mice and too much time on their hands.

    GUIs are indeed very slow but very user friendly, you generally don't have to think or remember much, in fact you could get away with guessing most of the time.

    But it all comes at the cost of speed and efficiency, I remember working for Target when the only input device was a keyboard and a CLI with some obscure layout that didn't make much sense at all. But after a couple off weeks I could fly through sales without taking my eyes off the customer. I didn't really need the monitor, only for it to confirm the change I should be giving back.

    Then they "updated" the system to a touch screen GUI that would make a snail angry with it's slowness. It would actually crash if you navigated the menus too fast, also the touch screens would slip up once every now and then hitting a wrong number, etc. The problem was no matter how well you knew the GUI you could not go any faster then a newbie.

    I like mutt quite a fair bit I even changed all my subscriptions to plain text so I was't presented with the standard view of having all images blocked till approved showing nothing. To having just what I need to know, and fly through without fussing with a mouse and loading irrelevant graphics.

    I even went extreme and installed archlinux and never bothered with installing a GUI, found all the alternatives and was quite happy with a reasonably well working graphicless, mouseless system that was instantaneously responsive. Unfortunately however is primary usefulness is to do work related tasks, it can play music but that's as much fun you'll get.

      Speaking of department stores.. Myer and David Jones need to axe their archaic checkout system which uses something akin to an Apple IIe.. any time they save using a command line interface is negated by the amount of time we customers wait for the receipts to be painfully produced by the dot matrix printers... coincidentally, i just google image'd "dot matrix printer" and the very first result was a panasonic dot matrix my family had when i was younger.

    If you're using a laptop you can swap mail settings automatically by location too. The .muttrc file supports setting variables to script output so something like the text below will set the settings for a known provider or default to gmail.

    ~/.muttrc:
    ...
    set smtp_url=`~/bin/set_smtp.pl`
    ...

    and ~/bin/set_smtp.pl:

    #!/usr/bin/perl

    my $resolv = '/etc/resolv.conf';

    my %smtps = (
    'default' => '"smtp://[email protected]:587/" smtp_pass="password"',
    'vic.optushome.com.au' => 'smtp://mail.optusnet.com.au',
    'optusnet.com.au' => 'smtp://mail.optusnet.com.au',
    # etc...
    );

    my $domain = 'default';

    open RESOLV, $resolv;

    while () {
    if (/^domain\s+(\S*)\s*$/) {
    $domain = $1;
    last;
    }
    }

    if ($smtps{$domain}) {
    print $smtps{$domain};
    } else {
    print $smtps{'default'};
    }

Join the discussion!

Trending Stories Right Now