2021-10-16 01:27:18 +02:00
← [[doom-module-index: ][Back to module index ]] ↙ [[doom-module-issues:::email notmuch ][Issues ]] ↖ [[doom-module-source:email/notmuch ][Source ]] ± [[doom-suggest-edit: ][Suggest edits ]] ? [[doom-help-modules: ][Help ]]
--------------------------------------------------------------------------------
#+TITLE : :email notmuch
#+SUBTITLE : Closest Emacs will ever be to multi-threaded
#+CREATED : May 05, 2019
#+SINCE : 2.0.0
* Description :unfold:
This module turns Emacs into an email client using [[doom-package: ][notmuch ]].
** Maintainers
*This module needs a maintainer.* [[doom-contrib-maintainer: ][Become a maintainer? ]]
** Module flags
- +afew ::
Enable integration with [[https://github.com/afewmail/afew ][afew ]].
- +org ::
Enable [[doom-package: ][org-mime ]] for writing HTML emails using org-mode.
** Packages
- [[doom-package: ][counsel-notmuch ]] if [[doom-module: ][:completion ivy ]]
- [[doom-package: ][helm-notmuch ]] if [[doom-module: ][:completion helm ]]
- [[doom-package: ][notmuch ]]
- [[doom-package: ][org-mime ]]* if [[doom-module: ][+org ]]
** TODO Hacks
#+begin_quote
🔨 This module's hacks haven't been documented yet. [[doom-contrib-module: ][Document them? ]]
#+end_quote
** TODO Changelog
# This section will be machine generated. Don't edit it by hand.
/This module does not have a changelog yet./
* Installation
[[id:01cffea4-3329-45e2-a892-95a384ab2338 ][Enable this module in your ~doom!~ block. ]]
2020-05-09 21:41:30 -05:00
This module requires:
2021-10-16 01:27:18 +02:00
+ Either [[https://github.com/gauteh/lieer ][gmailieer ]] (default), [[https://isync.sourceforge.io/ ][mbsync ]] or [[http://www.offlineimap.org/ ][offlineimap ]] -- to sync mail with.
+ [[https://notmuchmail.org/ ][notmuch ]] -- to index and tag your downloaded messages.
+ [[https://github.com/afewmail/afew ][afew ]] -- optionally to initially tag your downloaded messages.
2020-05-09 21:41:30 -05:00
** TODO MacOS
2020-11-26 09:49:22 -08:00
** Arch Linux
2021-10-16 01:27:18 +02:00
Run one of the following commands:
#+begin_src sh
2021-03-05 20:57:25 -05:00
pacman -S isync notmuch #mbsync
2021-10-16 01:27:18 +02:00
#+end_src
#+begin_src sh
2021-03-05 20:57:25 -05:00
pacman -S offlineimap notmuch
2021-10-16 01:27:18 +02:00
#+end_src
2020-09-12 12:53:21 -07:00
See: [[https://wiki.archlinux.org/index.php/Notmuch ][Arch Wiki - Notmuch ]]
2020-05-09 21:41:30 -05:00
** NixOS
2021-10-16 01:27:18 +02:00
#+begin_src nix
2020-05-09 21:41:30 -05:00
environment.systemPackages = with pkgs; [
notmuch
# And one of the following
gmailieer
isync
offlineimap
];
2021-10-16 01:27:18 +02:00
#+end_src
2020-05-09 21:41:30 -05:00
[[https://github.com/Emiller88/dotfiles/blob/319841bd3b89e59b01d169137cceee3183aba4fc/modules/shell/mail.nix ][An example of setting up mbsync and notmuch with home-manager ]]
** TODO openSUSE
** TODO Debian/Ubuntu
2020-09-12 12:53:21 -07:00
2021-10-16 01:27:18 +02:00
* TODO Usage
#+begin_quote
🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module: ][Complete it? ]]
#+end_quote
| Keymap | Command | Description |
|-----------------+--------------------+-----------------------------------------------|
| [[kbd:][<localleader> u]] | ~+notmuch/update~ | Download, sync, and index emails with notmuch |
| [[kbd:][<localleader> c]] | ~+notmuch/compose~ | Compose new email |
2021-05-06 22:27:08 -07:00
2021-10-16 01:27:18 +02:00
* TODO Configuration
#+begin_quote
🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module: ][Complete it? ]]
#+end_quote
2020-05-09 21:41:30 -05:00
2021-03-05 22:16:43 -05:00
** Downloading your email
To download your email you need a sync backend. Out of the box, this module
supports =Gmailier= (the default), =mbsync= , and =offlineimap= (ordered by
speed). You may define a custom one as well. The guides below will walk you
through setting them up with notmuch.
Later, once you've set up a sync backend and downloaded your email, you must
index your email for the first time:
2021-10-16 01:27:18 +02:00
#+begin_src sh
2021-03-05 22:16:43 -05:00
notmuch new
2021-10-16 01:27:18 +02:00
#+end_src
2021-03-05 22:16:43 -05:00
2021-05-06 22:34:20 -07:00
*** lieer
2021-10-16 01:27:18 +02:00
[[https://github.com/gauteh/lieer ][Lieer ]], formerly called Gmailieer, is the indexing tool used by default. To
install lieer, see the [[https://github.com/gauteh/lieer#installation ][installation docs ]].
2021-03-05 22:16:43 -05:00
*** offlineimap
To use [[https://www.offlineimap.org/ ][offlineimap ]], change ~+notmuch-sync-backend~ :
2021-10-16 01:27:18 +02:00
#+begin_src emacs-lisp
;; add to $DOOMDIR/config.el
2020-05-09 21:41:30 -05:00
(setq +notmuch-sync-backend 'offlineimap)
2021-10-16 01:27:18 +02:00
#+end_src
2020-05-09 21:41:30 -05:00
2021-03-05 22:16:43 -05:00
Next, write a configuration file for =offlineimap= . [[https://github.com/OfflineIMAP/offlineimap/blob/master/offlineimap.conf][Here is a comprehensive
example]] and [[https://github.com/OfflineIMAP/offlineimap/blob/master/offlineimap.conf.minimal ][another minimal one ]].
2020-05-09 21:41:30 -05:00
2021-03-05 22:16:43 -05:00
As a real world example, [[https://github.com/hlissner/dotfiles/blob/5f146b6c39552c0cf38025406f5dba7389542b0a/shell/mu/.offlineimaprc ][here is my old config ]], where it is configured to
2021-10-16 01:27:18 +02:00
download mail to =$HOME/.mail= . I used [[https://www.passwordstore.org/ ][unix pass ]] to securely store my login
2021-03-05 22:16:43 -05:00
credentials.
2020-05-09 21:41:30 -05:00
2021-10-16 01:27:18 +02:00
Finally, download your email with ~$ offlineimap -o~ . This may take a while,
2021-03-05 22:16:43 -05:00
especially if you have thousands of emails.
2020-05-09 21:41:30 -05:00
2021-03-05 22:16:43 -05:00
*** mbsync
To use [[https://isync.sourceforge.io/ ][mbsync ]], change ~+notmuch-sync-backend~ :
2021-10-16 01:27:18 +02:00
#+begin_src emacs-lisp
2020-05-09 21:41:30 -05:00
(setq +notmuch-sync-backend 'mbsync)
2021-03-05 22:16:43 -05:00
;; Use `mbsync-xdg' if your mbsync config lives in $XDG_CONFIG_HOME/isync:
(setq +notmuch-sync-backend 'mbsync-xdg)
2021-10-16 01:27:18 +02:00
#+end_src
2020-05-09 21:41:30 -05:00
2021-03-05 22:16:43 -05:00
The steps needed to set up =notmuch= with =mbsync= are similar to the ones for
2020-05-09 21:41:30 -05:00
[[*offlineimap ][offlineimap ]].
2021-10-16 01:27:18 +02:00
Start with writing a =$HOME/.mbsyncrc= to store your configuration. An example
for GMAIL can be found on the [[https://wiki.archlinux.org/index.php/isync#Configuring ][ArchWiki ]] which will also explain how its
integration with notmuch for auto synchronization. A non-GMAIL example is
available as a gist [[https://gist.github.com/agraul/60977cc497c3aec44e10591f94f49ef0 ][here ]].
2020-05-09 21:41:30 -05:00
2021-10-16 01:27:18 +02:00
Finally, download your email with ~$ mbsync --all~ . This may take a while, but
2021-03-05 22:16:43 -05:00
will be quicker than =offlineimap= .
2020-05-09 21:41:30 -05:00
2021-03-05 22:16:43 -05:00
*** Custom method
If you have a unique method for synchronizing your email, you can define your
own backend:
2021-10-16 01:27:18 +02:00
#+begin_src emacs-lisp
2021-03-05 22:16:43 -05:00
(setq +notmuch-sync-backend 'custom
;; Set this to an arbitrary shell command
+notmuch-sync-command "my-notmuch-sync-cmd")
2021-10-16 01:27:18 +02:00
#+end_src
2021-05-06 22:35:17 -07:00
** Sending mail
- [[https://notmuchmail.org/notmuch-emacs/#index6h2 ][notmuch docs: Sending mail ]]
- [[https://notmuchmail.org/emacstips/#index11h2 ][notmuch docs: msmtp, message mode and multiple accounts ]]
- [[https://notmuchmail.org/emacstips/#index12h2 ][notmuch docs: sending mail using smtpmail ]]
2021-10-16 01:27:18 +02:00
2020-09-12 12:53:21 -07:00
** Customize =*notmuch-hello*= buffer
It is possible to change the =*notmuch-hello*= buffer if you want to.
2021-10-16 01:27:18 +02:00
#+begin_src emacs-lisp
;; add to $DOOMDIR/config.el
2021-03-05 20:57:25 -05:00
(after! notmuch
2020-09-12 12:53:21 -07:00
(setq notmuch-show-log nil
notmuch-hello-sections `(notmuch-hello-insert-saved-searches
notmuch-hello-insert-alltags)
2021-03-05 22:16:43 -05:00
;; To hide headers while composing an email
2020-09-12 12:53:21 -07:00
notmuch-message-headers-visible nil))
2021-10-16 01:27:18 +02:00
#+end_src
2020-09-12 12:53:21 -07:00
** Changing the =notmuch= landing page
2021-03-05 20:57:25 -05:00
You may want to forego the =*notmuch-hello*= buffer by having ~M-x =notmuch~ or
2021-10-16 01:27:18 +02:00
[[kbd: ][<leader> o m ]] take you straight to a search page.
2020-09-12 12:53:21 -07:00
2021-10-16 01:27:18 +02:00
When using [[kbd: ][<leader> o m ]] the ~+notmuch-home-function~ is called. By default it
uses the ~notmuch~ function and so has the same familiar behavior of running a
2021-03-05 20:57:25 -05:00
vanilla install of notmuch-emacs. But, by overwriting this function you can run
a custom search as your landing page.
2021-10-16 01:27:18 +02:00
#+begin_src emacs-lisp
2020-09-12 12:53:21 -07:00
(setq +notmuch-home-function (lambda () (notmuch-search "tag:inbox")))
2021-10-16 01:27:18 +02:00
#+end_src
2021-05-10 21:17:30 -07:00
** Writing HTML Emails
2021-10-16 01:27:18 +02:00
The [[https://github.com/org-mime/org-mime ][org-mime ]] package provides functionality for composing emails in org-mode and
transforming them to HTML. This feature is enabled using the =+org= flag.
2021-05-10 21:17:30 -07:00
Example use cases:
2021-10-16 01:27:18 +02:00
- To convert an email to an HTML email use ~M-x org-mime-htmlize~ .
- To compose email using an org-mode editor buffer, use ~M-x
org-mime-edit-mail-in-org-mode~.
If you'd like to make configuration changes to =org-mime= , you may do so
normally. By default the output of =org-mime-htmlize= includes section numbers,
a byline, and a table of contents. That's probably more formal than the emails
you're used to sending, so here's some example configuration that turns those
features off:
2021-05-10 21:17:30 -07:00
#+begin_src emacs-lisp
2021-10-16 01:27:18 +02:00
;; add to $DOOMDIR/config.el
2021-05-10 21:17:30 -07:00
(after! org-mime
(setq org-mime-export-options '(:section-numbers nil
:with-author nil
:with-toc nil)))
#+end_src
2021-10-16 01:27:18 +02:00
* Troubleshooting
/There are no known problems with this module./ [[doom-report: ][Report one? ]]
* Frequently asked questions
/This module has no FAQs yet./ [[doom-suggest-faq: ][Ask one? ]]
2020-09-12 12:53:21 -07:00
2021-10-16 01:27:18 +02:00
* TODO Appendix
#+begin_quote
🔨 This module has no appendix yet. [[doom-contrib-module: ][Write one? ]]
#+end_quote