mu4e: an E-mail Client for Emacs

mu4e: an E-mail Client for Emacs

I am a long time user of Gmail and during this time I have become frustrated by
its online editing experience. Now, thanks to mu4e I am able to view, edit, send
and receive emails without the need to switch from my beloved editor – Emacs.

Here is an example of how to set up Gmail on Debian 6.

1 Get mu4e

Download the latest mu4e stable release from Google Code:
http://code.google.com/p/mu0/downloads/list

2 Install Dependencies

  • must
    $ sudo apt-get install libgmime-2.6-dev libxapian-dev gnutls-bin
    
  • optional
    $ sudo apt-get install guile-2.0-dev html2text xdg-utils
    

3 Build and Install mu4e

  • Move mu4e tarball to tmp
    $ mv ~/Downloads/mu-0.9.9.tar.gz /tmp && cd /tmp
    
  • Unzip
    $ tar xzvf mu-0.9.9.tar.gz & cd mu-0.9.9
    
  • Build
    $ ./configure && make
    
  • Install
    $ sudo make install
    

4 Configure offlineimap

There are a few sample configurations:
http://www.djcbsoftware.nl/code/mu/mu4e/Example-configurations.html#Example-configurations

For gmail, create `~/.offlineimaprc’ and put in:

[general]
accounts = Gmail
maxsyncaccounts = 3

[Account Gmail]
localrepository = Local
remoterepository = Remote

[Repository Local]
type = Maildir
localfolders = ~/Maildir

[Repository Remote]
type = IMAP
remotehost = imap.gmail.com
remoteuser = renws1990@gmail.com
remotepass = xxx
ssl = yes
maxconnections = 1
realdelete = no

Note: Replace remoteuser and remotepass with your own username and password.

5 Get emails

Run offlineimap, this will take some time.

$ offlineimap

Now index your messages

$ mu index --maildir=~/Maildir

This message might appear “database needs update; try ‘mu index –rebuild’, okay:

$ mu index --rebuild
$ mu index

6 Configure .emacs

Move the mu4e folder to your load-path (in my case, “~/.emacs.d/dotEmacs/”). Then
configure .emacs, add:

;;----------------------------------------------------------
;; ---- BEGIN Email client ----
;;----------------------------------------------------------
(add-to-list 'load-path "~/.emacs.d/dotEmacs/mu4e")
(require 'mu4e)

;; default
(setq mu4e-maildir "~/Maildir")
(setq mu4e-drafts-folder "/[Gmail].Drafts")
(setq mu4e-sent-folder   "/[Gmail].Sent Mail")
(setq mu4e-trash-folder  "/[Gmail].Trash")

;; don't save message to Sent Messages, Gmail/IMAP takes care of this
(setq mu4e-sent-messages-behavior 'delete)

;; setup some handy shortcuts
;; you can quickly switch to your Inbox -- press ``ji''
;; then, when you want archive some messages, move them to
;; the 'All Mail' folder by pressing ``ma''.

(setq mu4e-maildir-shortcuts
      '( ("/INBOX"               . ?i)
         ("/[Gmail].Sent Mail"   . ?s)
         ("/[Gmail].Trash"       . ?t)
         ("/[Gmail].All Mail"    . ?a)))

;; allow for updating mail using 'U' in the main view:
(setq mu4e-get-mail-command "offlineimap")

;; something about ourselves
(setq
 user-mail-address "renws1990@gmail.com"
 user-full-name  "任文山 (Ren Wenshan)"
 message-signature
 (concat
  "任文山 (Ren Wenshan)\n"
  "Email: renws1990@gmail.com\n"
  "Blog: wenshanren.org\n"
  "Douban: www.douban.com/people/renws"
  "\n"))

;; sending mail -- replace USERNAME with your gmail username
;; also, make sure the gnutls command line utils are installed
;; package 'gnutls-bin' in Debian/Ubuntu

(require 'smtpmail)
;; (setq message-send-mail-function 'smtpmail-send-it
;;       starttls-use-gnutls t
;;       smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil))
;;       smtpmail-auth-credentials
;;       '(("smtp.gmail.com" 587 "renws1990@gmail.com" nil))
;;       smtpmail-default-smtp-server "smtp.gmail.com"
;;       smtpmail-smtp-server "smtp.gmail.com"
;;       smtpmail-smtp-service 587)

;; alternatively, for emacs-24 you can use:
(setq message-send-mail-function 'smtpmail-send-it
    smtpmail-stream-type 'starttls
    smtpmail-default-smtp-server "smtp.gmail.com"
    smtpmail-smtp-server "smtp.gmail.com"
    smtpmail-smtp-service 587)

;; don't keep message buffers around
(setq message-kill-buffer-on-exit t)

;;----------------------------------------------------------
;; ---- END Email client ----
;;----------------------------------------------------------

Note Replace the user-mail-address, user-full-name, message-signature with your
own email address, full name and signature.

7 Use it!

Restart Emacs, you should now be able to fire up mu4e by typing `M-x
mu4e’. You can also type `M-x info mu4e’ to read its manual, which is very
handy.

In next section, I’ll introduce the most frequently used functions and their
key-bindings.

7.1 mu4e-main

First, type `M-x mu4e’ to get into mu4e’s main buffer.

key-bindings description
U update emails
j-i jump to `inbox’
j-s jump to `sent’
s search
C compose a new email

7.2 mark

After entering of the mail directories, you will see a buffer that is very
similar to dired and you can use similar keystrokes.

key-bindings description
? mark as unread
D delete
d move to trash
u remove mark at point
U remove all marks
x execute
R compose reply at point
Enter read email at point
q quit

7.3 view emails

key-bindings description
q quit
R compose reply

7.4 edit emails

key-bindings description
C-c C-c send

8 Screen-shots

8.1 mu4e main buffer

../Emacs/mu4e_main.png

8.2 mark/read emails

../Emacs/mu4e_read_email.png

Note: English is not my first language, so please feel free to point out any
mistakes you might find.


Date: 2013-01-28

Author: 任文山 (Ren Wenshan)

Org version 7.9.3d with Emacs version 24

Validate XHTML 1.0

6 thoughts on “mu4e: an E-mail Client for Emacs

  1. Pingback: Emacs: Which is the best e-mail client for Emacs? - Quora

  2. Miggs

    offlineimap gives me:
    OfflineIMAP 6.5.4
    Licensed under the GNU GPL v2+ (v2 or any later version)
    Account sync Gmail:
    *** Processing account Gmail
    Establishing connection to imap.gmail.com:993
    ERROR: Server SSL fingerprint ‘***’ for hostname ‘imap.gmail.com’ does not match configured fingerprint. Please verify and set ‘cert_fingerprint’ accordingly if not set yet.
    *** Finished account ‘Gmail’ in 0:00
    ERROR: Exceptions occurred during the run!
    ERROR: Server SSL fingerprint ‘***’ for hostname ‘imap.gmail.com’ does not match configured fingerprint. Please verify and set ‘cert_fingerprint’ accordingly if not set yet.

    I installed mu4e and offlineimap package from Ubuntu 13.04 official repository.

    Reply
    1. el

      i’ve solved this by append line:

      cert_fingerprint = ***

      into .offlineimparc (section [Repository Remote])

      Reply

Leave a Reply