# Mutt on Mac OS X

I am a big fan of the Mutt email client. Unfortunately, I also really like my iMac, and getting Mutt to work on it is always a headache. So I usually just retreat into my shell and put up with Mail.app. It’s not bad, after all. But it’s also not Mutt.

I have a Dell running Gentoo at Alexis’ house, and working on that recently I was reminded what a sine qua non Mutt actually is. So this morning I sucked it up, rolled up my sleeves, and got to work.

First, of course, download Mutt. I save it to desktop, so the next steps are obviously:

 cd ~/Desktop tar xvzf mutt-1.5.18.tar.gz cd mutt-1.5.18 

Then you gotta configure it, and this is where the trouble always shows up. Mutt (as of 1.5) comes with smtp support built in – which is a minor violation of its design philosophy, but was much appreciated back when I was still unaware of the magic that is Getmail. Even with Getmail in the background, I still compile with smtp support … just in case. These instructions were borrowed from linsec.ca:

 ./configure --prefix=/sw --with-curses --with-regex --enable-locales-fix --enable-pop --enable-imap --enable-smtp --with-sasl=/sw --enable-hcache --with-ssl --mandir=/sw/share/man 

The trouble for me always comes with the

 --enable-hcache 

flag. This requires a nice database manager in the background – apparently either QDDBM, GDBM, or Berkeley DB4. So, I installed Berkeley DB4: Berkeley DB 4.7.25.tar.gz.

 cd ~/Desktop tar xvzf db-4.7.25.tar.gz cd db-4.7.25.tar.gz/build_unix ../dist/configure make sudo make install 

Which installs Berkeley DB4 in /usr/local/BerkeleyDB.4.7/

And that, ladies and gentlemen, is the problem. Mutt isn’t expecting to find it there, and I then generally spend a couple of hours pulling my hair out trying to figure out why this thing that I clearly installed can’t be seen by Mutt. I’m not completely stupid, you see: I do know about things like the CPPFLAGS and LDFLAGS options to configure, which are meant to tell the compiler where to find libraries it can’t find in the usual/expected places. For some reason I don’t understand, these have never been any help compiling Mutt. But it seems there is a command line flag that tells Mutt exactly where BerkeleyDB4 is if you installed it. Here’s the list again; see if you can spot the difference:

 ./configure --prefix=/sw --with-curses --with-regex --enable-locales-fix --enable-pop --enable-imap --enable-smtp --with-sasl=/sw --enable-hcache --with-bdb=/usr/local/BerkeleyDB.4.7 --with-ssl --mandir=/sw/share/man 

Yes, apparently --with-bdb=/prefix is there for the express purpose of telling Mutt where to find the database. All this time and I never knew… Well, no one but myself to blame – it’s right there in the configure script if you bother to read it.

At this point Mutt compiles without complaint. You’ll notice that the guy at linsec.ca (Adam someone – whose name I should probably be able to reconstruct but can’t) asks everything to install at /sw, which is where things installed by Fink tend to go on Mac OS X. I put it here too, having no better ideas about where it should go – and if you choose to then you’ll have to make it visible to the main system in some way. This means you either add /sw to your PATH variable (probably via ~/.profile), or you make a symbolic link to some folder such as /usr/bin where your system is already expecting command-line programs to be:

 cd /usr/bin ln -s /sw/bin/mutt mutt 

Now you should be able to type mutt on the commandline from any directory in your system and be in business.

The next step is the dreaded configuration of sendmail. Unless I’m very much mistaken, sendmail is already on your Leopard system (it was already there for me – though I’m blonde, so it might be there because I installed it at some point in the mist-shrouded past of a month ago and subsequently forgot), so you don’t have to install it. But you do have to get it to do what you want, and as with anything this can be a bit tricky…

…which is why I don’t bother. There’s also this bit of black magic called putmail.py – as the name implies, a Python MTA. Actually a fairly minimalist one: it’s tailored to people like me who need to send mail, but not do anything fancy – just username, password, send, thank you very much. And that’s what it does for smtp. Installing it and setting it up is the easiest thing in the world – just read the helpful man page and it’ll take you 5min. tops. The config file goes in ~/.putmail/putmailrc. Here’s mine:

 [config] server = smtp.server.name email = my_email_username@domain.name username = my_email_username password = my_password tls = yes 

(The last line is necessary to get it to go through IU.)

Now we have the ability to send mail and read it, but we’ve still gotta actually get some mail to read.

The standard thing to do here is use fetchmail – but I feel the same way about that I feel about sendmail: too much trouble so long as there’s Getmail in the world. The link goes to the latest platform-neutral version unixy version. Getmail has the same basic advantage that putmail.py does: it’s written in Python, so it installs easily and works out of the box whereever a cool enough (read: >2.3 at the time of writing) version of Python is installed:

 tar xvzf getmail-4.8.4.tar.gz cd getmail-4.8.4 python setup.py build python setup.py install 

DONE! Well, except for the configuration. Configuration files go in ~/.getmail/getmailrc. Like with putmail.py, it’s all so simple there’s little point in walking anyone through it – but for reference here’s my file for talking to my Gmail account:

 [retriever] type = SimpleIMAPSSLRetriever server = imap.gmail.com username = my_username password = my_password mailboxes = ("INBOX", )

 [destination] type = Mboxrd path = ~/Mail/inbox 

[options] read_all = false 

A couple of things to point out. First – this tells Getmail to store my mail in mbox format, which is pretty standard UNIX, but may not be right for everyone (basically – it’s a giant text file with all your mail in the same file). And I’ve also told it to call this mbox file “inbox” and put it in a folder called “Mail” in my home directory. I mention this because it’s important to tell Mutt where to look for mail. Finally, I’ve set read_all to false to make sure it only gets those messages it’s not gotten before. Fail to do this, and you’ll end up with tons of duplicates in your inbox. Another way around this problem is to do delete = true, which deletes messages from the server as soon as it retrieves them. I go in and set it that way about once a week to do a quick mailbox cleanout – but otherwise it’s nice to leave about a week’s worth of messages on the server so that I can run mutt on several computers (laptop, iMac and Gentoo machine) without having to cart my mail between them. (More accurately, you have to toggle this on and off – because when set to false it only retrieves mail that’s never been read in any session, so it is a minor headache. Probably there is a good solution to this, but my version is just to delete the inbox mbox and redownload each time – poor man’s version control. When you’re keeping your mail to within a week, it’s not inconvenient.)

You do this – where else? – in your muttrc file – which it’s customary to hide in plain sight in your home directory, like so: ~/.muttrc. The best thing to do is copy the one they give you with your Mutt distribution – which has all the options typed in and commented out. You uncomment the ones you want to use and change the values to taste.

 cd ~/Desktop/mutt-1.5.18/doc cp Muttrc ~/.muttrc 

One can, of course, spend days fine-tuning Mutt to taste (which is the whole point of it, really – a mail client that does what YOU want for once), but the bare minimum to get it running is this:

 set mbox="~/Mail/inbox" set mbox_type=mbox set sendmail="/usr/local/bin/putmail.py" set spoolfile="~/Mail/inbox" 

And now it does the basics! If at this point in your life you type getmail on the command line, wait for it to finish and then type mutt, you’ll be reading your mail in the world’s coolest mail client. Naturally there’s no point in dealing with Mutt if “the basics” is all you want – but from this point it’s all a matter of what you like. So – go through your muttrc file and/or read the excellent Woodnotes Guide to the Mutt Email Client to get you started and have fun with it!

## 2 thoughts on “Mutt on Mac OS X”

1. chris says:

is there a reason to compile it yourself instead of using macports?

2. Joshua says:

Not that I know of. I’m allergic to MacPorts from having used it back in the day when it was difficult/annoying. It’s gotten much better recently, so I should get over my prejudice.