Answers:
我正在使用具有两个帐户的mu4e。每个帐户都有自己的maildir:
~/Mail
|
+---- work
|
`---- private
该手册附带一个用于选择帐户的示例功能:
(defun my-mu4e-set-account ()
"Set the account for composing a message."
(let* ((account
(if mu4e-compose-parent-message
(let ((maildir (mu4e-message-field mu4e-compose-parent-message :maildir)))
(string-match "/\\(.*?\\)/" maildir)
(match-string 1 maildir))
(completing-read (format "Compose with account: (%s) "
(mapconcat #'(lambda (var) (car var))
my-mu4e-account-alist "/"))
(mapcar #'(lambda (var) (car var)) my-mu4e-account-alist)
nil t nil nil (caar my-mu4e-account-alist))))
(account-vars (cdr (assoc account my-mu4e-account-alist))))
(if account-vars
(mapc #'(lambda (var)
(set (car var) (cadr var)))
account-vars)
(error "No email account found"))))
;; ask for account when composing mail
(add-hook 'mu4e-compose-pre-hook 'my-mu4e-set-account)
为此,您还需要my-mu4e-account-alist
:
(defvar my-mu4e-account-alist
'(("private"
(user-mail-address "private@domain.net")
(user-full-name "My Name")
(mu4e-sent-folder "/private/Sent Items")
(mu4e-drafts-folder "/private/Drafts")
(mu4e-trash-folder "/private/Deleted Items")
(mu4e-refile-folder "/private/Archive"))
("work"
(user-mail-address "work@domain.net")
(mu4e-sent-folder "/work/Sent Items")
(mu4e-drafts-folder "/work/Drafts")
(mu4e-trash-folder "/work/Deleted Items")
(mu4e-refile-folder "/work/Archives"))))
(setq mu4e-user-mail-address-list
(mapcar (lambda (account) (cadr (assq 'user-mail-address account)))
my-mu4e-account-alist))
j
只要您的所有maildirs是的子目录,您都可以简单地在邮件文件夹之间切换mu4e-maildir
。
实际上,我在使用更复杂的功能,mu4e-trash-folder
并mu4e-refile-folder
避免将电子邮件从一个maildir转移到另一个maildir,但是上面的信息对于使用多个帐户应该足够了。
我正在使用两个我想尽可能少混合的帐户。
offlineimap配置有两个帐户,一个帐户将邮件发送到~/.maildir-work
另一个帐户中~/.maildir-home
。
我对mu4e的配置使用了新的上下文机制:
(setq mu4e-contexts
`( ,(make-mu4e-context
:name "home"
:match-func (lambda (_) (string-equal "home" (mu4e-context-name mu4e~context-current)))
:enter-func '()
:leave-func (lambda () (mu4e-clear-caches))
:vars '((mu4e-maildir . "~/.maildir-home")
(mu4e-mu-home . "~/.mu-home")
(mu4e-get-mail-command . "offlineimap -a Home")
...))
,(make-mu4e-context
:name "work"
:match-func (lambda (_) (string-equal "work" (mu4e-context-name mu4e~context-current)))
:enter-func '()
:leave-func (lambda () (mu4e-clear-caches))
:vars '((mu4e-maildir . "~/.maildir-work")
(mu4e-mu-home . "~/.mu-work")
(mu4e-get-mail-command . "offlineimap -a Work")
...))))
mu4e-inbox-folder
变数,当我按此按钮时,ji
我会从我所有的帐户中收到传入的邮件,而不仅仅是工作或私人环境。