In this post I talk about three great new features in the latest release of mu4e, an email programme that runs in Emacs. I also show my mu4e configuration as an example to others who would like a similar setup.
After recently discovering that plaintext format=flowed in Thunderbird works only partially, it was time to check back in on mu4e after my previous happy stint using it.
I was pleasantly surprised to see that mu4e development had been quite active, and that this Emacs mail user agent had acquired a number of highly useful new features.
Three features I find particularly interesting are:
As I explained in another blog post,
format=flowed is a really clever extension to old-school plain text emails that enables any receiving mail app that supports the standard to reflow emails for better display on smaller or larger displays.
mu4e now has first-class and deterministic support of the
I do understand that HTML has won the email format war.
However, HTML formatting gives users entirely too much freedom when writing their emails, resulting in misguided typesetting and other unnecessary visual elements, analogous to and just as irritating as chart junk, that regularly damage sensitive eyes.
This is why I prefer writing in plain text. With reliable
format=flowed support, mu4e enables me to focus on the content whilst fixing plain-text email’s only real flaw: Reflowing on mobile devices.
This, just like anything else, one could previously implement by oneself in emacs-lisp. However, it’s now a welcome core feature activated via the
When you press
C to compose a new email, a separate frame (this is what Emacs calls a window) is opened. After sending the email with
C-c C-c the frame is automatically closed.
In my previous setup, I had made a bunch of emacs-lisp functions to switch between different email identities (from addresses).
This worked, but it was not nearly as convenient and well thought-out as mu4e’s new contexts.
I now have a separate context defined for each email identity. I can switch between them using
; followed by the self-configured shortcut character.
They also activate automatically based on a configurable match function, for example examining the destination address of an email I am replying to. My configuration example below shows this in a little more detail.
Because of these new features and a number of other changes, I put together this new configuration from scratch based on mu4e’s excellent documentation and examples.
I am still using `offlineimap` to synchronise my email with the IMAP server (fastmail in my case), but I’m currently sending email using the Emacs
Here is a slightly shortened and simplified version of my configuration:
;; I installed mu4e from the 0.9.18 tarball ;; this is where make install put the emacs bits (add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu4e") (require 'mu4e) ;; I want my format=flowed thank you very much ;; mu4e sets up visual-line-mode and also fill (M-q) to do the right thing ;; each paragraph is a single long line; at sending, emacs will add the ;; special line continuation characters. (setq mu4e-compose-format-flowed t) ;; every new email composition gets its own frame! (window) (setq mu4e-compose-in-new-frame t) ;; give me ISO(ish) format date-time stamps in the header list (setq mu4e-headers-date-format "%Y-%m-%d %H:%M") ;; show full addresses in view message (instead of just names) ;; toggle per name with M-RET (setq mu4e-view-show-addresses 't) ;; path to our Maildir directory (setq mu4e-maildir "~/Maildir") ;; the next are relative to `mu4e-maildir' ;; instead of strings, they can be functions too, see ;; their docstring or the chapter 'Dynamic folders' (setq mu4e-sent-folder "/Sent" mu4e-drafts-folder "/Drafts" mu4e-trash-folder "/Trash") ;; the maildirs you use frequently; access them with 'j' ('jump') (setq mu4e-maildir-shortcuts '(("/Archive" . ?a) ("/INBOX" . ?i) ("/Sent" . ?s))) ;; the list of all of my e-mail addresses (setq mu4e-user-mail-address-list '("firstname.lastname@example.org" "email@example.com" "firstname.lastname@example.org")) ;; the headers to show in the headers list -- a pair of a field ;; and its width, with `nil' meaning 'unlimited' ;; (better only use that for the last field. ;; These are the defaults: (setq mu4e-headers-fields '( (:date . 25) ;; alternatively, use :human-date (:flags . 6) (:from . 22) (:subject . nil))) ;; alternatively, use :thread-subject ;; program to get mail; alternatives are 'fetchmail', 'getmail' ;; isync or your own shellscript. called when 'U' is pressed in ;; main view. ;; If you get your mail without an explicit command, ;; use "true" for the command (this is the default) ;; when I press U in the main view, or C-c C-u elsewhere, ;; this command is called, followed by the mu indexer (setq mu4e-get-mail-command "offlineimap") ;; not using smtp-async yet ;; some of these variables will get overridden by the contexts (setq send-mail-function 'smtpmail-send-it message-send-mail-function 'smtpmail-send-it smtpmail-smtp-server "smtp.fastmail.com" smtpmail-smtp-service 465 smtpmail-stream-type 'ssl ) ;; don't keep message buffers around (setq message-kill-buffer-on-exit t) ;; here come the contexts ;; I have about 5 of these, chopped down to 2 for demonstration purposes ;; each context can set any number of variables (see :vars) ;; for example below here I'm using two different SMTP servers depending on identity (setq mu4e-contexts `( ,(make-mu4e-context :name "c email@example.com" :enter-func (lambda () (mu4e-message "Enter firstname.lastname@example.org context")) :leave-func (lambda () (mu4e-message "Leave email@example.com context")) ;; we match based on the contact-fields of the message (that we are replying to) ;; https://www.djcbsoftware.nl/code/mu/mu4e/What-are-contexts.html#What-are-contexts :match-func (lambda (msg) (when msg (mu4e-message-contact-field-matches msg :to "firstname.lastname@example.org"))) :vars '( ( user-mail-address . "email@example.com" ) ( user-full-name . "Charl P. Botha" ) ( smtpmail-smtp-server . "smtp.fastmail.com" ) ( mu4e-compose-signature . (concat "dr. charl p. botha\n" "http://charlbotha.com/\n")))) ,(make-mu4e-context :name "s firstname.lastname@example.org" :enter-func (lambda () (mu4e-message "Enter email@example.com context")) ;; no leave-func ;; we match based on the contact-fields of the message :match-func (lambda (msg) (when msg (mu4e-message-contact-field-matches msg :to "firstname.lastname@example.org"))) :vars '( ( user-mail-address . "email@example.com" ) ( user-full-name . "Charl P. Botha" ) ( smtpmail-smtp-server . "smtp.gmail.com" ) ( mu4e-compose-signature . (concat "Dr. Charl P. Botha\n" "Science Officer :: Stone Three Venture Technology\n" "https://www.stonethree.com\n")))) )) ;; start with the first (default) context; (setq mu4e-context-policy 'pick-first) ;; compose with the current context if no context matches; (setq mu4e-compose-context-policy nil) ;; these are the standard mu4e search bookmarks ;; I've only added the fourth one to pull up flagged emails in my inbox ;; I sometimes use this to shortlist emails I need to get around to ASAP (setq mu4e-bookmarks `( ,(make-mu4e-bookmark :name "Unread messages" :query "flag:unread AND NOT flag:trashed" :key ?u) ,(make-mu4e-bookmark :name "Today's messages" :query "date:today..now" :key ?t) ,(make-mu4e-bookmark :name "Last 7 days" :query "date:7d..now" :key ?w) ,(make-mu4e-bookmark :name "Flagged in INBOX" :query "maildir:\"/INBOX\" and flag:flagged" :key ?f)))
This is currently running smoothly on two of my Linux workstations as well as my early 2015 retina MacBook Pro.
The general setup procedure is to install offlineimap using
pip2 install --user offlineimap (the offlineimap configuration file hasn’t changed much since the previous post), run offlineimap for the first time, then build and install mu4e from its tarball, and finally to run
mu index to initialise the index.
After this, your mail, and plain-text nirvana, is a simple
M-x mu4e away.