I have a lot of eml files, archived from an account, and stored in a bunch of folders, one per month. It's not a standard maildir structure, and the files don't have special names, they're just like:
2015-01/
foo.eml
bar.eml
...
2015-02/
baz.eml
qux.eml
...
etc
I would like to make them accessible, read-only, over IMAP, preferably using dovecot, without changing the structure/naming if possible. It would be great if all the emails can appear together in the inbox, but separate folders by month (as they are structured on disk) are ok too.
To make this work you'll have to at least move these messages into a MailDir like structure. My Dovecot maildir looks like this for the account [email protected]
If you make a new sub-folder, say 'Archive' it would look like this:
The tmp, new and cur are directories created by Dovecot when you make this new folder in a client (eg: Roundcube). When a new sub-folder of Archive is created the directory structure becomes:
So, you will need to adjust your directory paths to make '2015-01' become something like:
Then, once these directories are created you'll copy the '.eml' files (which I hope are just plain-text email of the type expected by Dovecot) into the target 'new' directory. Connect with your preferred IMAP client and all is well.
I think I found a way to set up a maildir structure without making any changes to the folders and files I have. I made a separate maildir folder in a different place, and used symlinks to point to my mail-containing folders, like this:
I gave dovecot write permissions to the maildir and its subdirs so that it can write its index files, new and tmp folders and whatnot, but it has no write permissions for the actual mail archive folders.
For the dovecot configuration (I'm only serving these files on this server, nothing else) I set
mail_location = maildir:/path/to/my/maildir
and used a static passdb and userdb.This setup worked, but I also encountered a few problems:
Solution: run
doveadm flags add '\Seen' mailbox 201x-xx
Solution: added a global ACL file containing:
* owner lr
So far so good, I'll update if anything else comes up.