EmacsWiki: mu4e (original) (raw)
mu4e is an email client for Emacs. It’s based on the mu email indexer/searcher.
It's not information overload. It's filter failure. --Prof. Shirky
mu4e’s mission is to be a better filter.
mu4e first appeared in mu 0.9.8
.
Features
- Fully search-based: there are no folders, only queries
- Fully documented, with example configurations
- User-interface optimized for speed, with quick key strokes for common actions
- Asynchronous; heavy actions don’t block emacs
- Support for non-English languages (“angstrom” will match “Ångström”)
- Support for signing and encryption
- Address auto-completion based on your existing messages
- Extensible with your own code and many already done snippets
Quickstart
This tutorial assumes you have use a tool such as mbsync
or mpop
to retrieve your mail into a maildir folder called ~/mail
.
Download mu
from your package manager, then, from the commandline, run:
mu init --maildir=~/mail --my-address=me@example.com
From Emacs, download Mu4e with M-x package-install RET mu4e RET
and run it with M-x mu4e
.
Press U
to update Mu4e’s mail listing, and bu
to see all your new mail or j
to jump to a maildir folder.
Tips
Context templates
Defining mu4e contexts for multiple email accounts:
(defun my-make-mu4e-context (context-name full-name mail-address signature)
"Return a mu4e context named CONTEXT-NAME with :match-func matching
folder name CONTEXT-NAME in Maildir. The context's user-mail-address',
user-full-name' and `mu4e-compose-signature' is set to MAIL-ADDRESS
FULL-NAME and SIGNATURE respectively.
Special folders are set to context specific folders."
(let ((dir-name (concat "/" context-name)))
(make-mu4e-context
:name context-name
:match-func
`(lambda (msg)
(when msg
(string-match-p
,(concat "^" dir-name)
(mu4e-message-field msg :maildir))))
:vars
`((user-mail-address . ,mail-address)
(user-full-name . ,full-name)
(mu4e-sent-folder . ,(concat dir-name "/Sent"))
(mu4e-drafts-folder . ,(concat dir-name "/Drafts"))
(mu4e-trash-folder . ,(concat dir-name "/Trash"))
(mu4e-refile-folder . ,(concat dir-name "/Archive"))
(mu4e-compose-signature . ,signature)))))
(setq mu4e-change-filenames-when-moving t)
You can then set an account:
(setq mu4e-contexts `(,(my-make-mu4e-context "account0" "john" "john@example.org" "emacs")))
Integrating with mbsync
I use mu4e with mbsync (and GMail). Since it takes a while, mbsync runs in a cron job every 10 minutes or so, which mostly works (and I don’t want mu4e to wait for a sync). However, sometimes I want to refresh my emails now (“Hey, I just sent you something…”). This code changes the meaning of the prefix argument to “U” so that it re-syncs when given a prefix and doesn’t otherwise.
(setq mu4e-get-mail-command "mbsync gmail")
(defun rjs/mu4e-update-mail-and-index (orig-fun prefix &rest args)
(interactive "P")
(if prefix (funcall orig-fun nil) (mu4e-update-index)))
(advice-add 'mu4e-update-mail-and-index
:around #'rjs/mu4e-update-mail-and-index)
(setq mu4e-change-filenames-when-moving t)
Links
- Source code (part of mu): https://github.com/djcb/mu
- Releases: https://github.com/djcb/mu/releases
- Homepage, screenshots: http://www.djcbsoftware.nl/code/mu/mu4e.html
- Introduction: http://emacs-fu.blogspot.com/2012/08/introducing-mu4e-for-email.html
- Full documentation:http://www.djcbsoftware.nl/code/mu/mu4e/index.html (includes examples of setups)
- Another simple setup with gmail (2013/01/28): http://wenshanren.org/?p=111
- Yet another simple setup with gmail (2012/10/12) : https://gist.github.com/areina/3879626
- Some more advanced configurations (2013): http://zmalltalker.com/linux/mu.html