Skip to content

Instantly share code, notes, and snippets.

@jubalh
Created Jul 18, 2017
Embed
What would you like to do?
mu4econf
;; mu mail indexer
(require 'mu4e)
;; set folders
(setq
mu4e-maildir "~/.mail" ;; top-level Maildir
mu4e-sent-folder "/sent" ;; folder for sent messages
mu4e-drafts-folder "/drafts" ;; unfinished messages
mu4e-trash-folder "/trash" ;; trashed messages
mu4e-refile-folder "/archive") ;; saved messages
;; mail retrieval
(setq
mu4e-get-mail-command "mbsync -a")
;; sending mail
(setq message-send-mail-function 'message-send-mail-with-sendmail)
(setq sendmail-program "msmtp")
(defun choose-msmtp-account ()
(if (message-mail-p)
(save-excursion
(let*
((from (save-restriction
(message-narrow-to-headers)
(message-fetch-field "from")))
(account
(cond
((string-match "mail1@example.com" from) "private")
((string-match "mail2@example.com" from) "work"))))
(setq message-sendmail-extra-arguments (list '"-a" account))))))
(setq message-sendmail-envelope-from 'header)
(add-hook 'message-send-mail-hook 'choose-msmtp-account)
;; differnt stores for different mail accounts
(setq mu4e-contexts
`( ,(make-mu4e-context
:name "private"
:match-func (lambda (msg) (when msg
(string-prefix-p "/private" (mu4e-message-field msg :maildir))))
:vars '(
(user-mail-address . "mail1@example.com")
(user-full-name . "Mickey Mouse")
(mu4e-sent-folder . "/private/Sent")
(mu4e-drafts-folder . "/private/Drafts")
(mu4e-trash-folder . "/private/Trash")
(mu4e-refile-folder . "/private/Archive")
))
,(make-mu4e-context
:name "work"
:match-func (lambda (msg) (when msg
(string-prefix-p "/work" (mu4e-message-field msg :maildir))))
:vars '(
(user-mail-address . "mail2@example.com")
(user-full-name . "Donal Duck")
(mu4e-sent-folder . "/work/Sent")
(mu4e-drafts-folder . "/work/Drafts")
(mu4e-trash-folder . "/work/Trash")
(mu4e-refile-folder . "/work/Archive")
))
))
;; set private as default context
(setq mu4e-context-policy 'pick-first)
;; autostart mu4e
(mu4e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment