Set Up Email in Emacs With mbsync and mu4e

This blog describes how I set up email in Emacs with the help of mbsync, mu and mu4e. First of all, I need a program to synchronize emails in my local drive with the server. There are several options for this purpose, with two of the most popular ones being offlineimap and mbsync. I actually tried offlineimap first and was able to make it work together with mu and mu4e. There are two methods to specify the password of email account in offlineimap’s or mbsync’s configuration files. The easiest way is to specify password in plain text directly in the configuration files, which may be a bad example for security reasons. The second one is to specify the password in a file, e.g. .authinfo and then encrypt the file with GnuPG. Offlineimap and mbsync both support a gpg decryption command to retrieve the password from the encrypted file (.authinfo.gpg). However it will ask passphrase for the gpg key every time.

Since I want to sync my emails automatically every several minutes in mu4e, it would be ridiculous if I need to enter the passphrase each time. gpg-agent can solve the problem by remembering the keys in background so that I only need to type the passphrase once when I started my computer. Unfortunately, offlineimap does not play well with gpg-agent and mu4e and that is exactly why I settled down on mbsync finally.

I have come across lots of excellent tutorials on this matter during my setup. I will not reinvent the wheel by posting how exactly I configured mbsync and mu4e. The following links should be sufficient if I ever face those problems again in the future.

  1. http://www.macs.hw.ac.uk/~rs46/posts/2014-01-13-mu4e-email-client.html
  2. http://code.lexarcana.com/posts/text-based-email-setup-with-mbsync-and-mu.html
  3. http://ict4g.net/adolfo/notes/2014/12/27/emacs-imap.html
  4. http://pragmaticemacs.com/emacs/master-your-inbox-with-mu4e-and-org-mode/
  5. http://eauth.blogspot.com.au/2010/12/gpg-agent-on-os-x.html

The last one the most import information about setting gpg-agent on mac os x.

Finally my settings can be found on github, mbsync and mu4e.

Related