2012-08-20

introducing mu4e, an e-mail client for emacs

background

I've haven't written too much here lately. This is because I have spent most of my emacs hacking time on mu4e, an emacs e-mail client. It's only slightly over six months old since its first release, but it has progressed rather quickly! So, I think it is time to give it an introduction to a wider audience. In future posts, I'll go into more detail.

E-mail is a very important means of communication for me; and for purposes of integration, it prefer to do my e-mail with emacs. For a long time, I used mutt with emacs as the editor; a few years back I switched to Wanderlust, and wrote a few articles about it.

There's a lot to like about Wanderlust: it's very featureful, and allows for a lot of customization. Still, there were a few things I was not fully happy with; the most important one was the speed of some operations; another annoyance was the fact that I got rather frequent cache-corruptions when using newer emacs versions.

So, what was I to do? Well, a few years back, I had written an e-mail indexer/searcher, called mu. It takes the messages in a maildir-folder, and allows you to query them. I wondered if I could use mu as the backend for an emacs-based e-mail client. So, I fired up emacs, started writing some code and some later I had a first version of… mu4e.

how does it work?

mu4e is an emacs front-end for mu; when you start it, mu4e connects to a mu server process (started on-demand). It accepts simple commands, and responds with emacs s-expressions, in asynchronous fashion. In practice, all the heavy work is done in this server process, and emacs shows the results when it is ready (usually almost instantly). Emacs does not need to wait for the backend, and things stay snappy, even with tens of thousands (or more) e-mail messages. The only operation that may still require some waiting is sending mail, since that uses the emacs built-in smtpmail, which blocks during its operation.

mu expects your e-mail messages to be stored in a maildir (a one-file-per-message system); you can get these mails there through tools like offlineimap or fetchmail. mu periodically indexes the messages, and stores the results in a Xapian database. A lot of what mu4e does is querying this database – so for example, what you see as 'my inbox folder' in the mu4e-frontend, is in fact just the result of a query of all message that happen to live in that folder. You can query for many things – message sender, subject, date, words in the body and more.

mu4e does not just query messages; it can also move messages between folders, delete them, modify their flags and so on (and afterwards update the database). All 'state' is in the file system, and the database is just a quick way to get to it; if you delete the database and then re-index, nothing is lost, and changes made with other tools (e.g. mutt) are picked up by mu as well.

trying mu4e

Some Linux distributions ship mu4e, but not necessarily a very recent version; and because mu4e is developing quickly, you may want to use the latest official release, or (if you are more adventurous) check out the git repository. You'll need GNU/Emacs 23 or 24, GLib, GMime >= 2.4 and Xapian.

After installing mu4e, you can check the mu4e manual, which should be fairly complete. In fact, one of the goals of mu4e is to make it easy to set up; for that reason, the documentation includes complete examples of how to set things up. The Getting started chapter should get you up to speed quickly.

So, give it a try if you're interested; the mu=/=mu4e project is very open to suggestions (and even bugs reports!), so feel free to put them here or subscribe to the mu mailing list.

a small tour

I'll end this with a number of screenshots, to give you a rough idea of how things look.

The main screen

When you start mu4e (M-x mu4e), you're taken to the main screen, which list the things you can do. The entries should speak for themselves. Note that you can define you're own bookmarks. In general, mu4e tries to make things as easy as possible, and provide auto-completions where possible.

The headers / view split-screen

The results of your queries are shown as a list of headers; if you click one of the headers, mu4e splits the screen horizontally (optionally, you can split the screen vertically, or only show the message view). You can customize the headers shown, re-order them and so on.

The message view supports html message, inline images, and has a mechanism to associate user-functions with messages and attachments (such as 'view in browser' or 'pipe through command'); see the manual for some examples.

The message composition view

Obviously, you can reply to messages, forward them, or compose a new message. For writing and sending messages, mu4e reuses emacs' built-in message-mode. There's support for auto-completing addresses (based on the e-mails you've sent/received before).

There's even (experimental) support for writing you're messages using org-mode, and then sending them as rich-text (html) messages.

parting thoughts

So, this was a short introduction to mu4e, barely scratching the surface, but hopefully conveying the main ideas. The manual discusses things in much more detail, and I'll write more about it in the future.

mu4e is still a young project, but, for what's it worth, I've been using it full-time for over six months, and a growing number of people are doing the same. So, if you're interested, give it try and let us know you think!

Have fun!

24 comments:

Konstantine Rybnikov said...

Very cool, thanks, I think I'll give it a try (never used emacs as email client, but I think it's time for that!).

p.s.: would you consider using something like http://sphinx.pocoo.org as a documentation engine? It looks much more awesome than your current documentation.

Stefano Canepa said...

Why I need to abandon gnus in favor of mu4e?

djcb said...

@k_bx: well, i'd like to target info files (so i can read the manual in emacs). texi2html's output is not the sexiest in the world; i guess that could be improved.

@stefano canepa: well, not trying to convert anyone; mu4e is different from gnus (e.g., search-based, asynchronous). maybe give it a try and see what you like/don't like?

sinewalker said...

got it to configure on Ubuntu 12.04 (a vanila install on a VM) when I added these packages:

libglib2.0-dev
libgmime-2.6-dev
libxapian-dev
texinfo (if you want to make doc)
gcc
g++

Then actual building failed with an error from emacs that it couldn't load library org (?!) during load of org-jsinfo. I had to install the actual elisp package to resolve this.

emacs-el

Now it's built, will install/configure and see how I go.

Surprisingly, even though configure/make was a bit of a hastle, it's still easier to figure this out than to figure out Gnus. Hopefully mu/mu4e will be enough to help me with my org-mode induced need to integrate everything into emacs, including email!

Unknown said...

Did you look at http://notmuchmail.org . By default it provides a emacs frontend.

djcb said...

@Sinewalker: thanks for the report! And good luck trying it out.

@Aneesh Kumar: sure, it's mentioned in the docs. the notmuch architecture is similar to mu4e, but the ui is rather different.

Konstantine Rybnikov said...

Yep, had the same error with org. Had to install emacs24-el (someone might want emacs23-el or something).

p.s.: fetching mail via fetchmail already

p.p.s: about sphinx -- while emacs support for ReStructuredText is not so cool and you can't, say, navigate through links, cool thing about RST format is that it is itself readable as a source. Just FYI.

Anonymous said...

How hard would it be to put a version of your ui on top of notmuch? I'm using notmuch and find the tagging and other language interfaces very useful. It seems to be a stronger indexing mechanism. Your UI looks easier to use than the notmuch emacs UI if it is extended a bit to allow support for user tagging and the notmuch search extensions.

djcb said...

@fairhavenhorn: i think it would be quite hard, but certainly you could try.

be_slayed said...

I've been very happy with mew and have vastly preferred it over other clients, but I like mu4e a lot. I'm particularly impressed by its state after only 6 months of development.

Anonymous said...

Congratulations on both mu and mu4e — I find them both a joy to work with.

Alex

Anonymous said...

I have been using mu4e the last weeks (months?). It's really nice! For a long time I looked for keyboard friendly mail clients but never got comfortable to clients like mutt, gnus or wanderlust. But mu4e changes this. It feels just right. The best about it is its search functionality. This client really sucks less ;)

skybert said...

Heya,

thanks for making mu4e, I've uesd it as my primary email client for several months now and love it.

I've used Gnus and VM for ten years, but mu4e is already superior - to my use cases.

On wish list is easy (to debug and set up) mail filtering (Gnus is terrible here) and better thread view, but the current features already make for a good, fast, no nonsene email client.

And while I'm at it: The new TAB completion of addresses in 0.9.8.5 is amazing! Finally. BBDB drove me crazy and maintaining .mailrc was getting tedious. Thanks again!

Keep it up, I'm looking forward to what the future holds for mu[4e].

-Torstein

djcb said...

@be_slayed, @Alex, @christianxxx, @skybert:

Thanks for the nice words! mu4e is still young, suggestions / patches are always welcome :)

Anonymous said...

Nice work!
UI looks neat (except lack of thread folding). I'm certainly give it longer use once I can actually read mail email with it (no offence but gpg support is crucial for me :)

Dan LaManna said...

This does look very promising, though I agree with Anonymous comment of gpg support being of utmost importance for me as well.

djcb said...

@Anonymous, @Dan LaManna: crypto support is under development, and should make it for the next release.

Dave Abrahams said...

The description of the asynchronous stuff reminded me of https://github.com/jwiegley/emacs-async . Have you seen it?

djcb said...

@Dave Abrahams: it is somewhat similar; the big difference is that emacs-async uses another emacs process, while mu4e uses a special mu-server process.

I am actually thinking about using emacs-async (when available) for sending mail.

Unknown said...

It's awesome, thanks.

However, I can't view HTML emails in mu4e, is it possible to use w3m for reading HTML emails?

djcb said...
This comment has been removed by the author.
Varun B Patil said...

I just wrote a small post on how to setup and use emacs + offlineimap + mu4e at

http://varunbpatil.github.io/2013/08/19/eom

Anonymous said...

Thank you very much for mu4e --- its amazing! As a long time vm user with a much too long thunderbird detour I'm happy to report using mu4e (together with offlineimap/dovecot/postfix) on a daily basis.

Erich

Anonymous said...

Mu4e is allright, but keybindings do not work in default evil mode.