Master your inbox with mu4e and org-mode

In the following I will put forward my philosophy on handling emails and then show how this is realised in emacs using mu4e and org-mode.

I couple of years ago I read an article by the economist Tim Harford which hugely influenced the way I handle my emails. The ideas in the article are not unique but they really struck a chord with me. My email philosophy can be distilled down to one key concept:

your inbox is not a todo list

Like many people I used to keep emails in my inbox as a way of reminding me of something I needed to do, but the fact is that an inbox is a rubbish todo list.

I also had folders for putting emails in and I would occasionally have a painful cleanout of my towering inbox, agonising over which folder to put an email in, or whether I should create a new folder for it. No more! As long as your email programme has a good search, then it is quicker to search than to use a filing system.

Now when I check my emails, I do one of the following

  • delete if it is rubbish
  • read and delete if it is not something I’ll need to revisit
  • read and archive if it is something I might need to look up again
  • reply and archive if it is something that will take less than a couple of minutes to reply to and I have the time
  • add to todo list and archive if it is something that requires an action or just needs a longer reply than I have time to write

To use this system effectively, all you really need is: (i) an email client with a good search function so you can archive all mail in the same folder and not worry about filing it neatly, and (ii) a good system for adding tasks from your emails to a todo list.

The mu4e email client in emacs, combined with org-mode for todo organisation is the perfect way to do both of these things. There is very good documentation on how to set up mu4e on the project web page, including configuring it to work well with gmail, so I won’t go over that here. What I will say is that mu4e is built on mu, a powerful email indexer so it has all of your search needs covered.

Apart from searching, mu4e integrates very well with org-mode to make it seamless to generate todo items from emails. To set this up, add the following to your emacs config file

;;store org-mode links to messages
(require 'org-mu4e)
;;store link to message if in header view, not to header query
(setq org-mu4e-link-query-in-headers-mode nil)

Now update your org-mode capture template to something like this

(setq org-capture-templates
      '(("t" "todo" entry (file+headline "~/todo.org" "Tasks")
         "* TODO [#A] %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n%a\n")))

This looks like the version we had before, but the extra %a adds a link to the file you are visiting when you invoke the capture template.

The beauty of this is that hitting C-c c t now generates a todo item that contains a link to the email you are currently viewing. So you have zero friction in creating a todo item to e.g. reply to an email by a certain deadline, and you can happily archive that email knowing that clicking the link in the todo item will take you directly back to it.

I moved from thunderbird to mu4e a couple of months ago and really haven’t looked back. The things I missed at first were some of the extensions I was using to: create email templates; remind me about attachments; and add a delay to outgoing email so that I could have an “undo send” functionality. Happily I’ve found solutions to all of these in mu4e and I’ll be covering them in future posts.

  • Pingback: Mu4e and Org Mode | Irreal()

  • Boyan Penkov

    This is super — I’d love to hear more about your mu4e config (I’m trying to set it up with offlineimap for a few gmail accounts)!

  • Daniel Doherty

    I have over 12 years of emails in folders and am interested in replacing them all with search. Any suggestions for migrating old emails and preserving the folder name as some sort of searchable tag?

    Also, wish mu4e integrated with BBDB so I can easily make email aliases.

    Any suggestions?

  • maacl

    Great post. Really looking forward to hear how you solved email templates.

    • I’ll write more about this soon, but I use yasnippet…

  • Pingback: 2015-12-21 Emacs News - sacha chua :: living an awesome life()

  • Rodrigo Amestica

    Thanks for this posting and links included. I have time now to burn and see if I can move away from wl into mu+mu4e. The database in wl (elmo) is a too difficult artefact for me.

    mu is oriented to searches and, therefore, the notion of folders is somewhat irrelevant. I cannot fully understand that approach.

    Folders for me are easy to remember names. If something comes to discussion then I would probably link that situation with a folder name and go there. Too many folders is obviously a problem, though. And I constantly struggle to decide which folder is the right one. So, I do not have a really happy life with folders.

    Could you elaborate an example in which a search would help for one specific situation without the need for a folder?

    Thanks again for this posting, fun reading.

    • If a mail is has a task associated with it, then I store a link to it as described above, which takes me right to the mail. However, in the case that I need to find an email for a piece of information, I do just rely on search, sometimes trying a few keywords until I find the mail I wanted.

      In fact, I would say that an organised folder system will sometimes make it easier to find mails than a simple search. The point for me is that most of the time it is not any faster, and the time saved by not manually filing emails enormously outweighs any time saved finding emails with a folder based system.

      Good luck moving over to mu4e!

      • Rodrigo Amestica

        I’m using mu4e daily now! At moments I just play with random searches just to be once more amazed of how fast they work, real nice! Attachments and links in a message are presented in a so, let’s say, professional way and mouseless that I love it. Re-indexing blocks emacs completely, and that’s getting in my way more often than I would prefer, I have not tried to understand how to improve that, if possible at all.

        Links, like you have explained here, are remarkable. When I moved to wl from tb, a few years back, I really expected to use links to messages from org-mode files a lot. But as far I learned, in wl as soon a I moved a message to some other directory within my maildir then that link became broken. My understanding is that mu searches for them each time I click the link. It just works.

        Thanks for you posting, it pushed me for a postponed change that now I’m happy with.

  • Gastove

    Hello! I found this post while trying to set up the same thing and hitting some really baffling errors. In case anyone else either a) is fighting with the same glitches, or b) has any idea how to fix them, I’ve written them up in the Usual Manner on the Emacs stack exchange: http://emacs.stackexchange.com/questions/21352/org-capture-mu4e-failures

    Mostly here, I’d love to ask what versions of Emacs/Org/mu4e you’re using? Something-something-weird-versions is sort of my last wild guess as to what’s causing my troubles.

    Thanks for the excellent posts!

    • Hi! I am using emacs 24.5.1 (from macports on os x), org version 8.3.3 and mu4e 0.9.16

      Have you tried asking on the mu4e google group – they are very helpful!

      https://groups.google.com/forum/#!forum/mu-discuss

      • Gastove

        Thanks very much! I think one of the messy bits of this issue is that it’s in the gap where mu4e and org meet — it’s very difficult to tell which of the two things might be at fault. (For instance: my versions are nearly identical to yours, and yet this doesn’t work at all. Neat?)

        Thanks for your time!