#+TITLE: Mu4e #+AUTHOR: Christopher James Hayward #+EMAIL: chris@chrishayward.xyz #+PROPERTY: header-args:emacs-lisp :tangle mu4e.el :comments org #+PROPERTY: header-args:shell :tangle no #+PROPERTY: header-args :results silent :eval no-export :comments org #+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil #+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil Plain-text email inside of Emacs. * Setup Make sure the following dependencies are installed on your system before loading the module. I would recommend against using any distributions pre-packaged version of ~mu4e~[fn:1], and instead build it yourself which I detail in this post[fn:2]: #+begin_src shell RUN apt install -y isync libgmime-3.0-dev libxapian-dev #+end_src ** Setting up mbsync :PROPERTIES: :header-args: :tangle ../config/mbsyncrc :comments org :END: The program that actually synchronizes the emails with the server is ~mbsync~[fn:3]. Create the configuration file, this is for my personal mail server[fn:4], which I host myself, so make sure you write your own. #+begin_src conf IMAPStore xyz-remote Host mail.chrishayward.xyz User chris@chrishayward.xyz PassCmd "pass chrishayward.xyz/chris" SSLType IMAPS MaildirStore xyz-local Path ~/.cache/mail/ Inbox ~/.cache/mail/inbox SubFolders Verbatim Channel xyz Master :xyz-remote: Slave :xyz-local: Patterns * !Archives Create Both Expunge Both SyncState * #+end_src ** Create symbolic links The system typically expects to find this file at =$HOME/.mbsyncrc=, but you may also specify a custom path if launching the command using arguments. I chose to symlink the default location to my repository. #+begin_src emacs-lisp (dotfiles/symlink "~/.emacs.d/config/mbsyncrc" "~/.mbsyncrc") #+end_src This repository also contains my personal encrypted auth info, this is required by ~mbsync~[fn:3] to sign all of the outbound messages. #+begin_src emacs-lisp (dotfiles/symlink "~/.emacs.d/config/authinfo.gpg" "~/.authinfo.gpg") #+end_src ** First time indexing Before you can use ~mu4e~[fn:1] inside of Emacs, you need to synchronize the mail database, and index it using ~mu~[fn:5], the library used by ~mu4e~[fn:1] under the hood. Execute these commands in your terminal before loading the module, after that you can do everything inside of Emacs: #+begin_src shell RUN mbsync -a RUN mu init --maildir="~/.cache/mail" --my-address="chris@chrishayward.xyz" RUN mu index #+end_src * Config After syncing and indexing, the mail is ready for Emacs. Include ~mu4e~[fn:1] in the configuration by adding the custom built version to the load path, and configure the mail account. + Update every 5 minutes + Configure mail account(s) + Scale text for all devices + Sign outbound mail with GPG key #+begin_src emacs-lisp (use-package mu4e :load-path "~/.local/source/mu/mu4e/" :custom (mu4e-maildir "~/.cache/mail") (mu4e-update-interval (* 5 60)) (mu4e-get-mail-command "mbsync -a") (mu4e-compose-format-flowed t) (mu4e-change-filenames-when-moving t) (message-send-mail-function 'smtpmail-send-it) (mml-secure-openpgp-signers '("37AB1CB72B741E478CA026D43025DCBD46F81C0F")) (mu4e-compose-signature (concat "Chris Hayward\n" "https://chrishayward.xyz\n")) :config (add-hook 'message-send-hook 'mml-secure-message-sign-pgpmime) (setq mu4e-contexts (list ;; Main ;; chris@chrishayward.xyz (make-mu4e-context :name "Main" :match-func (lambda (msg) (when msg (string-prefix-p "/Main" (mu4e-message-field msg :maildir)))) :vars '((user-full-name . "Christopher James Hayward") (user-mail-address . "chris@chrishayward.xyz") (smtpmail-smtp-server . "mail.chrishayward.xyz") (smtpmail-smtp-service . 587) (smtpmail-stream-type . starttls)))))) #+end_src ** Desktop notifications Receive desktop notifications when new mail arrives with the ~mu4e-alert~[fn:6] package. #+begin_src emacs-lisp (use-package mu4e-alert :after mu4e :custom (mu4e-alert-set-default-style 'libnotify) :config (mu4e-alert-enable-notifications) (mu4e-alert-enable-mode-line-display)) #+end_src * Shortcuts Open the ~mu4e~[fn:1] dashboard with =SPC m=. #+begin_src emacs-lisp (dotfiles/leader "m" '(mu4e :which-key "Mu4e")) #+end_src * Footnotes [fn:1] https://emacswiki.org/emacs/mu4e [fn:2] https://chrishayward.xyz/posts/installing-mu-mu4e-from-source/ [fn:3] https://isync.sourceforge.io [fn:4] mailto:chris@chrishayward.xyz [fn:5] https://codewith.mu/en/download [fn:6] https://github.com/iqbalansari/mu4e-alert