2019-05-05 14:11:59 -04:00
#+TITLE : email/mu4e
2019-01-05 16:50:08 -05:00
#+DATE : April 8, 2017
#+SINCE : v2.0
#+STARTUP : inlineimages
2017-05-04 10:40:51 +02:00
2019-01-05 16:50:08 -05:00
* Table of Contents :TOC:
2019-08-27 10:50:37 +02:00
- [[#description ][Description ]]
- [[#module-flags ][Module Flags ]]
- [[#plugins ][Plugins ]]
- [[#prerequisites ][Prerequisites ]]
- [[#macos ][MacOS ]]
- [[#arch-linux ][Arch Linux ]]
- [[#nixos ][NixOS ]]
- [[#opensuse ][openSUSE ]]
2020-04-24 12:09:38 +02:00
- [[#debianubuntu ][Debian/Ubuntu ]]
2019-08-27 10:50:37 +02:00
- [[#features ][Features ]]
- [[#configuration ][Configuration ]]
- [[#offlineimap ][offlineimap ]]
- [[#mbsync ][mbsync ]]
2020-04-24 12:09:38 +02:00
- [[#mu-and-mu4e ][mu and mu4e ]]
2020-04-01 21:14:58 -04:00
- [[#troubleshooting ][Troubleshooting ]]
- [[#no-such-file-or-directory-mu4e ][=No such file or directory, mu4e= ]]
2020-04-18 18:59:22 -04:00
- [[#void-function-org-time-add-error-on-gentoo ][~(void-function org-time-add)~ error on Gentoo ]]
2019-01-05 16:50:08 -05:00
* Description
2017-05-25 20:08:50 +02:00
This module makes Emacs an email client, using ~mu4e~ .
2017-05-04 10:40:51 +02:00
#+begin_quote
2019-01-05 16:50:08 -05:00
I want to live in Emacs, but as we all know, living is incomplete without email.
So I prayed to the text editor gods and they (I) answered. Emacs+evil's editing
combined with org-mode for writing emails? /Yes please./
2017-05-25 20:08:50 +02:00
2019-01-05 16:50:08 -05:00
It uses ~mu4e~ to read my email, but depends on ~offlineimap~ (to sync my email
via IMAP) and ~mu~ (to index my mail into a format ~mu4e~ can understand).
2017-05-04 10:40:51 +02:00
#+end_quote
2019-01-05 16:50:08 -05:00
** Module Flags
+ ~+gmail~ Enables gmail-specific configuration.
** Plugins
2020-04-27 14:09:06 -04:00
This module install no plugins.
2017-08-21 20:07:07 +02:00
2019-01-05 16:50:08 -05:00
* Prerequisites
2017-05-25 20:08:50 +02:00
This module requires:
2019-01-05 16:50:08 -05:00
+ Either ~mbsync~ (default) or ~offlineimap~ (to sync mail with)
2020-04-27 14:09:06 -04:00
+ ~mu~ , to index your downloaded messages and to provide the ~mu4e~ package.
2017-05-25 20:08:50 +02:00
2017-08-21 20:07:07 +02:00
** MacOS
2019-01-05 16:50:08 -05:00
#+BEGIN_SRC sh
2020-02-01 22:35:16 -05:00
brew install mu
2019-01-05 16:50:08 -05:00
# And one of the following
brew install isync # mbsync
2017-05-04 10:40:51 +02:00
brew install offlineimap
#+END_SRC
2017-08-21 20:07:07 +02:00
** Arch Linux
2019-12-09 10:54:27 +01:00
Run one of the following commands.
2019-01-05 16:50:08 -05:00
#+BEGIN_SRC sh
sudo pacman -S isync # mbsync
2020-04-08 15:29:29 -04:00
# OR
2019-01-05 16:50:08 -05:00
sudo pacman -S offlineimap
#+END_SRC
2019-12-09 10:54:27 +01:00
Install ~mu~ , which is not available in the main repositories but in the AUR, by
using for example the AUR helper ~yay~ .
#+BEGIN_SRC sh
yay -S mu
#+END_SRC
2019-07-19 13:24:25 -05:00
** NixOS
#+BEGIN_SRC nix
environment.systemPackages = with pkgs; [
mu
# And one of the following
isync
offlineimap
];
#+END_SRC
2020-05-09 20:58:15 -05:00
[[https://github.com/Emiller88/dotfiles/blob/5eaabedf1b141c80a8d32e1b496055231476f65e/modules/shell/mail.nix ][An example of setting up mbsync and mu with home-manager ]]
2019-01-05 16:50:08 -05:00
2019-08-27 10:50:37 +02:00
** openSUSE
2019-11-21 14:45:18 -05:00
Remove ~#~ in ~#sync_program=offlineimap~ to choose ~offlineimap~ instead of
~mbsync~ .
2019-08-27 10:50:37 +02:00
#+BEGIN_SRC sh :dir /sudo::
sync_program=isync # mbsync
#sync_program=offlineimap
2019-11-21 14:45:18 -05:00
2020-04-16 09:24:54 +02:00
sudo zypper install maildir-utils $sync_program
2019-08-27 10:50:37 +02:00
#+END_SRC
2020-04-16 09:24:54 +02:00
** Debian/Ubuntu
Run the command corresponding to the desired backend and the last one.
#+BEGIN_SRC sh
sudo apt-get install isync # mbsync
# or
sudo apt-get install offlineimap
# then
sudo apt-get install maildir-utils # mu
#+END_SRC
2019-01-05 16:50:08 -05:00
* TODO Features
* Configuration
** offlineimap
2020-04-24 12:09:38 +02:00
This module uses =mbsync= by default. To use =offlineimap= , change ~+mu4e-backend~ :
2019-01-05 16:50:08 -05:00
#+BEGIN_SRC emacs-lisp
2019-05-05 14:11:59 -04:00
(setq +mu4e-backend 'offlineimap)
2017-05-04 10:40:51 +02:00
#+END_SRC
2020-04-24 12:09:38 +02:00
Next, you need to write a configuration file for =offlineimap= . Mine can be found
[[https://github.com/hlissner/dotfiles/tree/master/shell/mu ][in my dotfiles repository ]]. It is configured to download mail to ~\~ /.mail~. I
use [[https://www.passwordstore.org/ ][unix pass ]] to securely store my login credentials. You can find a *very*
detailed configuration [[https://github.com/OfflineIMAP/offlineimap/blob/master/offlineimap.conf ][here ]].
2017-05-04 10:40:51 +02:00
2020-04-24 12:09:38 +02:00
Next you can download your email with ~offlineimap -o~ . This may take a while,
especially if you have thousands of mails.
2020-05-29 02:00:04 -05:00
You can now proceed with the [[mu and mu4e ][mu and mu4e ]] section.
2020-04-24 12:09:38 +02:00
** mbsync
The steps needed to set up =mu4e= with =mbsync= are very similar to the ones for
2020-05-29 02:00:04 -05:00
[[offlineimap ][offlineimap ]].
2020-04-24 12:09:38 +02:00
Start with writing a ~\~ /.mbsyncrc~. An example for GMAIL can be found on
[[http://pragmaticemacs.com/emacs/migrating-from-offlineimap-to-mbsync-for-mu4e/ ][pragmaticemacs.com ]]. A non-GMAIL example is available as a gist [[https://gist.github.com/agraul/60977cc497c3aec44e10591f94f49ef0 ][here ]]. The [[http://isync.sourceforge.net/mbsync.html][manual
page]] contains all needed information to set up your own.
Next you can download your email with ~mbsync --all~ . This may take a while, but
should be quicker than =offlineimap= ;).
2020-05-29 02:00:04 -05:00
You can now proceed with the [[mu and mu4e ][mu and mu4e ]] section.
2020-04-24 12:09:38 +02:00
** mu and mu4e
You should have your email downloaded already. If you have not, you need to set
=offlineimap= or =mbsync= up before you proceed.
Before you can use =mu4e= or the cli program =mu= , you need to index your email
initially. How to do that differs a little depending on the version of =mu= you
use. You can check your version with ~mu --version~ .
For =mu= *>=1.4* you need to run two commands:
#+BEGIN_SRC sh
mu init --maildir ~/.mail --my-address email@example.com
mu index
#+END_SRC
=mu= *<1.4* only requires one command:
#+BEGIN_SRC sh
mu index --maildir ~/.mail
#+END_SRC
2017-05-04 10:40:51 +02:00
Then configure Emacs to use your email address:
#+BEGIN_SRC emacs-lisp :tangle no
2019-05-05 14:11:59 -04:00
;; Each path is relative to `+mu4e-mu4e-mail-path', which is ~/.mail by default
2019-01-05 16:50:08 -05:00
(set-email-account! "Lissner.net"
'((mu4e-sent-folder . "/Lissner.net/Sent Mail")
(mu4e-drafts-folder . "/Lissner.net/Drafts")
(mu4e-trash-folder . "/Lissner.net/Trash")
(mu4e-refile-folder . "/Lissner.net/All Mail")
(smtpmail-smtp-user . "henrik@lissner.net")
2020-04-24 12:09:38 +02:00
(user-mail-address . "henrik@lissner.net") ;; only needed for mu < 1.4
2019-01-05 16:50:08 -05:00
(mu4e-compose-signature . "---\nHenrik Lissner"))
t)
2017-05-04 10:40:51 +02:00
#+END_SRC
2017-05-25 20:08:50 +02:00
2020-04-01 21:14:58 -04:00
* Troubleshooting
** =No such file or directory, mu4e=
You will get =No such file or directory, mu4e= errors if you don't run ~doom
sync~ after installing =mu= through your package manager.
2020-04-18 18:59:22 -04:00
** ~(void-function org-time-add)~ error on Gentoo
Gentoo users will see this error because [[https://gitweb.gentoo.org/repo/gentoo.git/tree/net-mail/mu/files/70mu-gentoo.el#n2][the =net-mail/mu= package eagerly loads
=mu4e= (which pulls in =org= ) much too early]]; before Emacs reads =~/.emacs.d= .
So early, that it loads the built-in version of org-mode, rather than the newer
version that Doom installs.
Later versions of the =net-mail/mu= package have [[https://gitweb.gentoo.org/repo/gentoo.git/commit/net-mail/mu?id=770e1fccb119fbce8ba6d16021a3598123f212ff ][fixed this issue ]], but you may
need to switch to the unstable build of =net-mail/mu= to see it.