Send email without invoking notmuch's backend
Discovered a bug with `use-package` where :config sections are not called if there is a :bind section.
This commit is contained in:
parent
334c3f9cff
commit
13b930e6ee
1 changed files with 88 additions and 73 deletions
69
ha-email.org
69
ha-email.org
|
@ -40,12 +40,12 @@ The configuration files below expect email addresses (I store passwords and othe
|
||||||
|
|
||||||
#+NAME: email-address-1
|
#+NAME: email-address-1
|
||||||
#+begin_src emacs-lisp :exports none :tangle no :results silent
|
#+begin_src emacs-lisp :exports none :tangle no :results silent
|
||||||
(rot13-string "ubjneq.noenzf@tznvy.pbz")
|
(rot13-string "ubjneq@ubjneqnoenzf.pbz")
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+NAME: email-address-2
|
#+NAME: email-address-2
|
||||||
#+begin_src emacs-lisp :exports none :tangle no :results silent
|
#+begin_src emacs-lisp :exports none :tangle no :results silent
|
||||||
(rot13-string "ubjneq@ubjneqnoenzf.pbz")
|
(rot13-string "ubjneq.noenzf@tznvy.pbz")
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+NAME: email-address-3
|
#+NAME: email-address-3
|
||||||
|
@ -53,29 +53,28 @@ The configuration files below expect email addresses (I store passwords and othe
|
||||||
(rot13-string "ubjneq@shmmlgbnfg.pbz")
|
(rot13-string "ubjneq@shmmlgbnfg.pbz")
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
To use these, we set the =:noweb yes= (to pull in the /name/ of the code block) but put a pair of parens after the name to have it evaluated. For instance:
|
To use these, we set the =:noweb yes= (to pull in the /name/ of the code block) but put a pair of parens after the name to have it evaluated. For instance, the configuration for sending mail through the MUA in Emacs:
|
||||||
#+begin_example
|
#+begin_src emacs-lisp :noweb yes
|
||||||
,#+begin_src conf :noweb yes :tangle /tmp/foobar.txt :results silent
|
(setq send-mail-function 'smtpmail-send-it
|
||||||
some-address: <<email-address-2()>>
|
message-send-mail-function 'smtpmail-send-it
|
||||||
,#+end_src
|
smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil))
|
||||||
#+end_example
|
smtpmail-auth-credentials `(("smtp.gmail.com" 587 ,<<email-address-1>> nil))
|
||||||
|
smtpmail-default-smtp-server "smtp.gmail.com"
|
||||||
|
smtpmail-smtp-server "smtp.gmail.com"
|
||||||
|
smtpmail-smtp-service 587)
|
||||||
|
#+end_src
|
||||||
* Installation and Basic Configuration
|
* Installation and Basic Configuration
|
||||||
|
|
||||||
To begin, we need the code. On Ubuntu, this is:
|
To begin, we need the code. On Ubuntu, this is:
|
||||||
|
|
||||||
#+begin_src shell :tangle no
|
#+begin_src shell :tangle no
|
||||||
sudo apt install -y notmuch
|
sudo apt install -y notmuch
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
And on MacOS, we use =brew=:
|
And on MacOS, we use =brew=:
|
||||||
|
|
||||||
#+begin_src shell :tangle no
|
#+begin_src shell :tangle no
|
||||||
brew install notmuch
|
brew install notmuch
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Next, we need some basic configuration settings and some global keybindings:
|
Next, we need some basic configuration settings and some global keybindings:
|
||||||
|
|
||||||
#+begin_src emacs-lisp :noweb yes
|
#+begin_src emacs-lisp :noweb yes
|
||||||
(use-package notmuch
|
(use-package notmuch
|
||||||
:init
|
:init
|
||||||
|
@ -92,20 +91,25 @@ Next, we need some basic configuration settings and some global keybindings:
|
||||||
notmuch-show-indent-content nil)
|
notmuch-show-indent-content nil)
|
||||||
|
|
||||||
:bind (:map notmuch-hello-mode-map
|
:bind (:map notmuch-hello-mode-map
|
||||||
("U" . notmuch-retrieve-messages) ; Defined later
|
("U" . notmuch-retrieve-messages)
|
||||||
("C" . notmuch-mua-new-mail)
|
("C" . notmuch-mua-new-mail)
|
||||||
:map notmuch-tree-mode-map
|
:map notmuch-tree-mode-map
|
||||||
("C" . notmuch-mua-new-mail))
|
("C" . notmuch-mua-new-mail))
|
||||||
:config (ha-leader ; Should I put these under an "m" heading?
|
|
||||||
|
:config
|
||||||
|
(ha-leader ; Should I put these under an "m" heading?
|
||||||
"a n" '("new mail" . notmuch-retrieve-messages)
|
"a n" '("new mail" . notmuch-retrieve-messages)
|
||||||
"a m" '("read mail" . notmuch)
|
"a m" '("read mail" . notmuch)
|
||||||
"a c" '("compose mail" . notmuch-mua-new-mail))
|
"a c" '("compose mail" . compose-mail))
|
||||||
|
|
||||||
<<local-leader-keybindings>>
|
<<local-leader-keybindings>>
|
||||||
|
|
||||||
(ha-mail-hello-leader
|
(ha-mail-hello-leader
|
||||||
"u" '("new mail" . notmuch-retrieve-messages)
|
"u" '("new mail" . notmuch-retrieve-messages)
|
||||||
"m" '("read mail" . notmuch)
|
"m" '("read mail" . notmuch)
|
||||||
"c" '("compose" . notmuch-mua-new-mail)
|
"c" '("compose" . notmuch-mua-new-mail)
|
||||||
"C" '("reply-later" . hey-notmuch-reply-later))
|
"C" '("reply-later" . hey-notmuch-reply-later))
|
||||||
|
|
||||||
<<hey-show-keybindings>>
|
<<hey-show-keybindings>>
|
||||||
<<hey-search-keybindings>>)
|
<<hey-search-keybindings>>)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
@ -117,16 +121,24 @@ Also, let's do some basic configuration of Emacs' mail system:
|
||||||
message-send-mail-function 'message-send-mail-with-sendmail
|
message-send-mail-function 'message-send-mail-with-sendmail
|
||||||
message-sendmail-envelope-from 'header)
|
message-sendmail-envelope-from 'header)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
Create a special mail perspective:
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(defun ha-email-persp-start ()
|
||||||
|
"Create an IRC workspace and start my IRC client."
|
||||||
|
(interactive)
|
||||||
|
(persp-switch "mail")
|
||||||
|
(notmuch))
|
||||||
|
|
||||||
|
(ha-leader "a M" '("mail persp" . ha-email-persp-start))
|
||||||
|
#+end_src
|
||||||
* Configuration
|
* Configuration
|
||||||
Do I want to sign messages by default? Nope.
|
Do I want to sign messages by default? Nope.
|
||||||
|
|
||||||
#+begin_src emacs-lisp :tangle no
|
#+begin_src emacs-lisp :tangle no
|
||||||
(add-hook 'message-setup-hook 'mml-secure-sign-pgpmime)
|
(add-hook 'message-setup-hook 'mml-secure-sign-pgpmime)
|
||||||
#+end_src
|
#+end_src
|
||||||
** Addresses
|
** Addresses
|
||||||
|
|
||||||
I need to incorporate an address book again, but in the meantime, searching through a history of past email works well enough.
|
I need to incorporate an address book again, but in the meantime, searching through a history of past email works well enough.
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(setq notmuch-address-selection-function
|
(setq notmuch-address-selection-function
|
||||||
(lambda (prompt collection initial-input)
|
(lambda (prompt collection initial-input)
|
||||||
|
@ -138,14 +150,11 @@ I need to incorporate an address book again, but in the meantime, searching thro
|
||||||
'notmuch-address-history)))
|
'notmuch-address-history)))
|
||||||
#+end_src
|
#+end_src
|
||||||
** Sending Messages
|
** Sending Messages
|
||||||
|
|
||||||
Do I need to set up [[https://marlam.de/msmtp/][MSMTP]]? No, as Notmuch will do that work.
|
Do I need to set up [[https://marlam.de/msmtp/][MSMTP]]? No, as Notmuch will do that work.
|
||||||
To do this, type ~c~ and select an option (including ~r~ to reply).
|
To do this, type ~c~ and select an option (including ~r~ to reply).
|
||||||
|
|
||||||
** Retrieving Messages
|
** Retrieving Messages
|
||||||
|
|
||||||
When we start notmuch, we need to retrieve the email and then process it. Most of this is actually contained in the Notmuch configuration.
|
When we start notmuch, we need to retrieve the email and then process it. Most of this is actually contained in the Notmuch configuration.
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(defun notmuch-retrieve-messages ()
|
(defun notmuch-retrieve-messages ()
|
||||||
"Retrieve and process my mail messages."
|
"Retrieve and process my mail messages."
|
||||||
|
@ -155,19 +164,22 @@ When we start notmuch, we need to retrieve the email and then process it. Most o
|
||||||
* iSync Configuration
|
* iSync Configuration
|
||||||
Using [[https://isync.sourceforge.io/][isync]] (or is it =mbsync=) for mail retrieval. I have a couple of Google Mail accounts that I want connected.
|
Using [[https://isync.sourceforge.io/][isync]] (or is it =mbsync=) for mail retrieval. I have a couple of Google Mail accounts that I want connected.
|
||||||
|
|
||||||
The file generally can have a =Pass= entry for the encrypted passcode, but to show how to connect to more than one accounts, I'm using a GPG daemon:
|
There are global settings:
|
||||||
|
|
||||||
#+begin_src conf :tangle ~/.mbsyncrc :noweb yes
|
#+begin_src conf :tangle ~/.mbsyncrc :noweb yes
|
||||||
# Note: We now tangle this file from ~/other/hamacs/ha-email.org
|
# Note: We now tangle this file from ~/other/hamacs/ha-email.org
|
||||||
Create Both
|
Create Both
|
||||||
SyncState *
|
SyncState *
|
||||||
MaxMessages 300
|
MaxMessages 100
|
||||||
Sync All # New ReNew Flags
|
Sync All # New ReNew Flags
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
The following section is for my /personal/ (not too general) account.
|
||||||
|
The file generally can have a =Pass= entry for the encrypted passcode, but to show how to connect to more than one accounts, I'm using a GPG daemon:
|
||||||
|
#+begin_src conf :tangle ~/.mbsyncrc :noweb yes
|
||||||
# PERSONAL ACCOUNT
|
# PERSONAL ACCOUNT
|
||||||
IMAPAccount personal
|
IMAPAccount personal
|
||||||
Host imap.gmail.com
|
Host imap.gmail.com
|
||||||
User <<email-address-2()>> # Substitute your own email address here
|
User <<email-address-1()>> # Substitute your own email address here
|
||||||
PassCmd "gpg --quiet --for-your-eyes-only --no-tty --decrypt ~/.mailpass-personal.gpg"
|
PassCmd "gpg --quiet --for-your-eyes-only --no-tty --decrypt ~/.mailpass-personal.gpg"
|
||||||
SSLType IMAPS
|
SSLType IMAPS
|
||||||
AuthMechs LOGIN
|
AuthMechs LOGIN
|
||||||
|
@ -197,11 +209,14 @@ The file generally can have a =Pass= entry for the encrypted passcode, but to sh
|
||||||
Master :personal-remote:"[Gmail]/Trash"
|
Master :personal-remote:"[Gmail]/Trash"
|
||||||
Slave :personal-local:trash
|
Slave :personal-local:trash
|
||||||
ExpireUnread yes
|
ExpireUnread yes
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
I have other email accounts that could use or ignore.
|
||||||
|
#+begin_src conf :tangle no
|
||||||
# GMAIL ACCOUNT
|
# GMAIL ACCOUNT
|
||||||
IMAPAccount gmail
|
IMAPAccount gmail
|
||||||
Host imap.gmail.com
|
Host imap.gmail.com
|
||||||
User <<email-address-1()>> # Substitute your own email address here
|
User <<email-address-2()>> # Substitute your own email address here
|
||||||
PassCmd "gpg -q --for-your-eyes-only --pinentry-mode loopback -d ~/.mailpass-google.gpg"
|
PassCmd "gpg -q --for-your-eyes-only --pinentry-mode loopback -d ~/.mailpass-google.gpg"
|
||||||
SSLType IMAPS
|
SSLType IMAPS
|
||||||
AuthMechs LOGIN
|
AuthMechs LOGIN
|
||||||
|
|
Loading…
Reference in a new issue