From 2bb145fab2b0a3c7053a391ac7db33442e29d5d6 Mon Sep 17 00:00:00 2001 From: Jakub Czajka Date: Fri, 23 Dec 2022 18:19:42 +0100 Subject: [PATCH] [emacs] Read and send email. This commit installs and configures clients for sending (`sendmail`) and receiving (`notmuch`) email. --- bash/.config/profile.d/50-notmuch.sh | 6 ++++ conf/home/emacs.scm | 14 +++++++++ emacs/.config/emacs/conf/conf-email.el | 42 ++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 bash/.config/profile.d/50-notmuch.sh create mode 100644 emacs/.config/emacs/conf/conf-email.el diff --git a/bash/.config/profile.d/50-notmuch.sh b/bash/.config/profile.d/50-notmuch.sh new file mode 100644 index 0000000..aac77a7 --- /dev/null +++ b/bash/.config/profile.d/50-notmuch.sh @@ -0,0 +1,6 @@ +# Copyright (c) 2022 Jakub Czajka +# License: GPL-3.0 or later. +# +# 50-notmuch.sh - environment variables for notmuch. + +export NOTMUCH_CONFIG="${XDG_CONFIG_HOME}/notmuch/notmuchrc" diff --git a/conf/home/emacs.scm b/conf/home/emacs.scm index 719c72c..584b77b 100644 --- a/conf/home/emacs.scm +++ b/conf/home/emacs.scm @@ -11,6 +11,7 @@ #:use-module (gnu packages emacs-xyz) #:use-module (gnu packages freedesktop) #:use-module (gnu packages gnupg) + #:use-module (gnu packages mail) #:use-module (gnu packages password-utils) #:use-module (gnu packages pdf) #:use-module (gnu packages rust-apps) @@ -78,6 +79,18 @@ (dotfiles (list "emacs/.config/emacs/conf/conf-document.el"))))) +(define emacs-email-service + (service home-program-service-type + (home-program-configuration + (packages + (list emacs-notmuch + isync + msmtp + notmuch)) + (dotfiles + (list "bash/.config/profile.d/50-notmuch.sh" + "emacs/.config/emacs/conf/conf-email.el"))))) + (define emacs-package-service (service home-program-service-type (home-program-configuration @@ -119,6 +132,7 @@ emacs-daemon-service emacs-dired-service emacs-document-service + emacs-email-service emacs-package-service emacs-pass-service emacs-service)) diff --git a/emacs/.config/emacs/conf/conf-email.el b/emacs/.config/emacs/conf/conf-email.el new file mode 100644 index 0000000..7aa8432 --- /dev/null +++ b/emacs/.config/emacs/conf/conf-email.el @@ -0,0 +1,42 @@ +;; Copyright (c) 2022 Jakub Czajka +;; License: GPL-3.0 or later. +;; +;; conf-email.el - configuration for the email client. + +(require 'conf-package) + +(use-package sendmail + :requires + (conf-crypt) + :when + (conf:executables-p (list "msmtp")) + :custom + ;; Use `sendmail' interface with `msmtp' backend. + (send-mail-function 'sendmail-send-it) + (sendmail-program "/usr/bin/msmtp") + ;; Use sender address from the `From' clause of the header. + (mail-specify-envelope-from t) + (message-sendmail-envelope-from 'header) + (mail-envelope-from 'header) + :config + ;; `dummy' is not a real password entry. It exists solely for this advices. + (define-advice message-send-mail-with-sendmail (:before ()) + (password-store-get "dummy"))) + +(use-package notmuch + :requires + (conf-crypt) + :when + (conf:executables-p (list "mbsync" "notmuch")) + :ensure t + :bind + ("C-c m" . notmuch) + :custom + (notmuch-archive-tags '("-inbox" "+archive")) + (notmuch-transient-prefix "?") + :config + ;; `dummy' is not a real password entry. It exists solely for this advices. + (define-advice notmuch-poll (:before ()) + (password-store-get "dummy"))) + +(provide 'conf-email) -- 2.39.5