mu4e is an emacs-based e-mail client. It’s based on the mu e-mail indexer/searcher. It attempts to be a super-efficient tool to withstand the daily e-mail tsunami.

To quote Prof. Shirky: It's not information overload. It's filter failure. mu4e’s mission is to be a better filter.



mu4e’s first release is as part of mu 0.9.8, end of January 2012, and the most recent one is 1.4.8, released in May 2020 (see


Context templates

Defining mu4e contexts for multiple email addresses that only differ in the “from” field and maybe signature, while automatically matching their corresponding address using their :match-func (when replying to messages) can quickly get pretty verbose and clunky. To keep it lean and avoid code duplication, one can define a function to build a context based on a template:

  (defun my-make-mu4e-context (name address signature)
    "Return a mu4e context named NAME with :match-func matching
  its ADDRESS in From or CC fields of the parent message. The
  context's `user-mail-address' is set to ADDRESS and its
  `mu4e-compose-signature' to SIGNATURE."
    (lexical-let ((addr-lex address))
      (make-mu4e-context :name name
                         :vars `((user-mail-address . ,address)
                                 (mu4e-compose-signature . ,signature))
                         (lambda (msg)
                           (when msg
                             (or (mu4e-message-contact-field-matches msg :to addr-lex)
                                 (mu4e-message-contact-field-matches msg :cc addr-lex)))))))

Then, easily define contexts:

    (setq mu4e-contexts
        `( ,(my-make-mu4e-context "main" ""
                                  "Emacs is awesome.")
           ,(my-make-mu4e-context "work" ""
                                  "A very professional signature.")
           ,(my-make-mu4e-context "other" ""
                                  "Plain text mail forever.")))

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")
    ;; Most of the time, I merely want mu4e to re-index my local maildir (because
    ;; I'm running mbsync as a cron job). However, sometimes I want to fetch mails
    ;; immediately. Do this by changing the meaning of a prefix for
    ;; mu4e-update-mail-and-index (bound to "U").
    ;; A prefix usually means run in the background, but I don't think I ever want
    ;; that. Change things so a prefix means to call mbsync.
    (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)