7

I'm trying to set mu4e to use for both personal and work gmail accounts. I successfully configured offlineimap and fetched the mail.

Then I tried setting mu4e, and according documentation:

the recommended way to deal with multiple accounts is through mu4e’s built-in Contexts system

Okay. I set the context values like this:

 mu4e-contexts
        `( ,(make-mu4e-context
             :name "home"
             :match-func (lambda (msg) (when msg (mu4e-message-contact-field-matches msg :to "personal-email@gmail.com")))
             :vars '((mu4e-maildir           . "~/.mail/personal")
                     (mu4e-trash-folder      . "/[Gmail].Trash")))
           ,(make-mu4e-context
             :name "work"
             :match-func (lambda (msg) (when msg (mu4e-message-contact-field-matches msg :to "work-email@gmail.com")))
             :vars '((mu4e-maildir           . "~/.mail/work")
                     (mu4e-trash-folder      . "/[Gmail].Bin"))))))

of course there's more than that, I'm showing you only the relevant piece. So the problem I'm having is have to do with deleting messages. Sometimes it works, other times it doesn't. And when it fails it throws messages like this:

  error in process filter: Error 70: error moving /Users/ag/.mail/personal/[Gmail].INBOX/cur/1457242634_2.42730.C02MT2ZDFH05,U=27933,FMD5=4b4b643246a6b95b2136ea99e0e5f614:2,S 
to /Users/ag/.mail/[Gmail].Trash/cur/1457242634_2.42730.C02MT2ZDFH05,U=27933,FMD5=4b4b643246a6b95b2136ea99e0e5f614:2,ST

You see that it picked file in personal dir and trying to move to [Gmail].Trash in root of maildir?

Actual directory tree looks more like this:

    /Users/ag/.mail
    ├── personal
    │   ├── INBOX
    │   ├── [Gmail].All\ Mail
    │   ├── [Gmail].Important
    │   ├── [Gmail].Sent\ Mail
    │   ├── [Gmail].Spam
    │   ├── [Gmail].Trash
    └── work
        ├── INBOX
        ├── [Gmail].All\ Mail
        ├── [Gmail].Bin
        ├── [Gmail].Important
        ├── [Gmail].Sent\ Mail
        ├── [Gmail].Spam

Note that mu4e-trash-folder values are different for personal and work. Honestly I dunno why - I set synclabels = yes in my offlineimaprc and that's what I got.

It seems to me, mu4e fails to set correct value of mu4e-trash-folder during context switching. Can someone help me fix that? Show me a piece of config where different folders being used for different contexts? Thanks.

iLemming
  • 1,223
  • 9
  • 14
  • 1
    The folders are different because your personal account uses American English and your work account uses British English. Gmail has folder names set based on your language preference. – nert Oct 06 '17 at 13:02

1 Answers1

9

You can't set mu4e-maildir in contexts.

cf. http://www.djcbsoftware.nl/code/mu/mu4e/Contexts-example.html

You can set any kind of variable; including settings for mail servers etc. However, settings such as mu4e-maildir and mu4e-mu-home are not changeable after they have been set without quitting mu4e first.

So, you should set as follows:

(setq mu4e-maildir "~/.mail"
      mu4e-contexts
    `( ,(make-mu4e-context
         :name "home"
         :match-func (lambda (msg) (when msg (mu4e-message-contact-field-matches msg :to "personal-email@gmail.com")))
         :vars '((mu4e-trash-folder      . "/personal/[Gmail].Trash")))
       ,(make-mu4e-context
         :name "work"
         :match-func (lambda (msg) (when msg (mu4e-message-contact-field-matches msg :to "work-email@gmail.com")))
         :vars '((mu4e-trash-folder      . "/work/[Gmail].Bin"))))))
lurdan
  • 1,071
  • 7
  • 11
  • If not setting `mu4e-maildir` in contexts, how does mu4e know which `INBOX` to use? There seems to be no `mu4e-inbox-folder` variable... – AstroFloyd May 04 '19 at 17:04
  • 1
    mu4e doesn't have to care where `INBOX` is. It simply indexes folders under `mu4e-maildir`, and `INBOX` may be one of them. – lurdan May 20 '19 at 01:12
  • Ah, I see, and if I really want to jump to some particular inbox, I can define `mu4e-maildir-shortcuts` to go there when I type e.g. `ji`. – AstroFloyd May 20 '19 at 16:44