Skip to content

Instantly share code, notes, and snippets.

Created Jul 18, 2017
What would you like to do?
;; mu mail indexer
(require 'mu4e)
;; set folders
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
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)
((from (save-restriction
(message-fetch-field "from")))
((string-match "" from) "private")
((string-match "" 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 . "")
(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")
:name "work"
:match-func (lambda (msg) (when msg
(string-prefix-p "/work" (mu4e-message-field msg :maildir))))
:vars '(
(user-mail-address . "")
(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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment