(config) emacs: add msmtp thingies

This commit is contained in:
Sakooooo 2024-10-20 16:49:05 +04:00
parent e74a6586b1
commit 25c483d69f
Signed by: sako
GPG key ID: FE52FD65B76E4751

View file

@ -1205,8 +1205,14 @@ GNU patch review metho dor sometihng idk
(setq mu4e-change-filenames-when-moving t)
;; sending mail
(setq message-send-mail-function 'smtpmail-send-it)
(add-to-list 'smtpmail-auth-supported 'xoauth2)
;;(setq message-send-mail-function 'smtpmail-send-it)
;;(add-to-list 'smtpmail-auth-supported 'xoauth2)
(setq send-mail-function 'sendmail-send-it)
(setq message-send-mail-function 'sendmail-sent-it)
(setq sendmail-program (executable-find "msmtp"))
;; select the right sender email from the context.
(setq message-sendmail-envelope-from 'header)
(setq mu4e-update-interval (* 10 60))
(setq mu4e-get-mail-command (format "INSIDE_EMACS=%s offlineimap" emacs-version)
@ -1216,6 +1222,24 @@ GNU patch review metho dor sometihng idk
;; for mail accounts
(setq sakomacs-mail-accounts (json-read-file "~/.mail/accounts.json"))
(defun sakomacs/set-msmtp-account ()
(if (message-mail-p)
(save-excursion
(let*
((from (save-restriction
(message-narrow-to-headers)
(message-fetch-field "from")))
(account
(cond
((string-match (cdr (assoc 'gmail-1 sakomacs-mail-accounts)) from) "gmail-1")
((string-match (cdr (assoc 'gmail-2 sakomacs-mail-accounts)) from) "gmail-2")
((string-match (cdr (assoc 'protonmail sakomacs-mail-accounts)) from) "protonmail")
((string-match (cdr (assoc 'li sakomacs-mail-accounts)) from) "li")
((string-match (cdr (assoc 'outlook sakomacs-mail-accounts)) from)))))
(setq message-sendmail-extra-arguments (list '"-a" account))))))
(add-hook 'message-send-mail-hook 'sakomacs/set-msmtp-account)
;; kill message buffers
(setq message-kill-buffer-on-exit t)