Using Mutt with Gmail on OSX

Published on January 19, 2010 by Jesse Storimer

What?

Mutt is a command-line email client whose motto is "All mail clients suck. This one just sucks less". Basically it brings email to your Terminal. You can find more information on their site.

Why?

  1. Lately I've had a bit of an obsession with command line tools. So the fact that mutt gives me command line access to my mail piqued my interest immediately :)

  2. I've always wanted tab-completion while writing emails, they are a repetitive medium. But GMail never offered that. With mutt I set TextMate to be my editor so I now write email messages in TextMate, which does have tab(escape) completion.

Installation

Install mutt from your favourite package management system.

brew install mutt

Customization

You will need to create a ~/.muttrc with your specific mutt configuration. This is the minimum required to get mutt working.

# ~/.muttrc
set imap_user = 'user@gmail.com'
set imap_pass = 'password'
set spoolfile = imaps://imap.gmail.com:993/INBOX
set folder = imaps://imap.gmail.com:993
set postponed=”imaps://imap.gmail.com/[Gmail]/Drafts”
set message_cachedir=”~/.mutt/cache/bodies”
set certificate_file=~/.mutt/certificates

You need to make sure that the ~/.mutt directories actually exist in order to mitigate funny certificate errors. If you want to know what other options are available you can check out my .muttrc or the mutt docs.

Opening URLs

Since mutt is a command line tool, you can't click links in your emails. You will need urlview in order to open URLs in emails. You will need to install urlview from source and apply a patch for Snow Leopard.

wget ftp://ftp.guug.de/pub/mutt/contrib/urlview-0.9.tar.gz
tar xvzf urlview-0.9.tar.gz
cd urlview-0.9
./configure
# apply the patch found here http://blog.joelesler.net/2009/12/getting-urlview-to-work-on-snow-leopard.html
make
make install

To open URLs in your default browser you need to create a ~/.urlview.

# ~/.urlview
COMMAND open %s

This tells mutt to use the open command on URLs, %s is a placeholder for the URL. Now, when reading an email in mutt, press <Ctrl>-b to see a list of links in the message and use your arrow keys and enter to select one.

HTML emails

You may quickly notice that by default mutt prints out the source of HTML emails, not very useful. It is true that everyone should be providing plain text email for command line lovers like us, but alas, some people are ignorant of this fact. In order to view HTML emails with mutt just add this line to your ~/.muttrc.

# ~/.muttrc
auto_view text/html

Cheating

I created a cheat sheet that has some common commands that you might use with mutt to manage your GMail. You can see the sheet online or access from the command line with cheat: cheat mutt_gmail.

I'm still a beginning mutt user (about 1 week), so I haven't yet explored all the nuances of the software. Particularly excited about looking into keyboard macros.


Like what you read?

Join 2,000+ Ruby programmers improving their skills with exclusive content about digging deeper with sockets, processes, threads, and more - delivered to your inbox weekly.

I'll never send spam and you can unsubscribe any time.


comments powered by Disqus