How to configure dovecot mail locations to have one user who has multiple imap accounts?

1.4k Views Asked by At

I have mbsync fetch two different email accounts to two different subdirectories of my home directory. Can I have dovecot configured to use both mail locations for a single user? My goal is let gnus (emacs) talk to dovecot to get the mail for both accounts keeping folders separate and distinct. I currently do this with a single location, but I am having trouble figuring out how to do it for two locations.

2

There are 2 best solutions below

1
On

Using aliases you can deliver messages to the arbitrary account in the mail system. Using sieve you can sort out those messages by original recipient to the different subfolders under the INBOX.

0
On

I made this much harder than it needed to be. There is really almost nothing to do if the right programs are pointing to the right directories.

To solve my problem I created two accounts with respective channels in my .mbsyncrc file. These use a shared maildir style inbox at, in my case ~/allmail/ with account one using ~/allmail/acct1 and account two using ~/allmail/acct2 . I tested and got that syncing fine after a few uid problems from some false starts.

I then edited the dovecot.conf file to use the above inbox and location by setting the mail_location line to:

mail_location = maildir:~/allmail/:LAYOUT=fs:INBOX=/home/me/allmail

Then restarted dovecot with

sudo systemctl restart dovecot

Made sure gnus had the right variables set for nnimap. I found it convenient to change the name from that used previously so that the group names in gnus were unique to the new structure I had set up. Then I could go into the server and subscribe to my new groups and kill the old ones, and trim a few bogus groups too.

Now I have all mail from both accounts stored locally, and I can use posting styles unique to each acct1 or acct2 groups to get the right return and gcc values as well as using msmtp to send mail from each account through the proper server.