Reputation: 5142
I have code that looks something like this
import imapclient
archive_folder = "Archive"
aggregate_reports_folder = "{0}/Aggregate".format(archive_folder)
forensic_reports_folder = "{0}/Forensic".format(archive_folder)
server = imapclient.IMAPClient("example.com", use_uid=True)
server.login("user", "foobar")
if not server.folder_exists(archive_folder):
server.create_folder(archive_folder)
if not server.folder_exists(aggregate_reports_folder):
server.create_folder(aggregate_reports_folder)
if not server.folder_exists(forensic_reports_folder):
server.create_folder(forensic_reports_folder)
It works fine on Office 365/Exchange, but not dovecot. On dovecot it causes an error:
Error: create failed: [CANNOT] Invalid mailbox name: Name must not have '/' characters
I tried removing the /subfolder
part of the folder name, and running select_folder(archive_folder)
first, but that just creates folders at the same level as Archive. Yet, Thunderbird can create subfolders without a problem.
How can I create IMAP subfolders using imapclient, in a way that works with all IMAP servers? Also, How do I move mail to those subfolders?
Upvotes: 1
Views: 1776
Reputation: 5142
I found the answer in the dovecot mailing list.
Currently Dovecot supports only Maildir++ directory layout, which specifies that '.' character is used as the separator in the filesystem.
So when building subfolder paths, use .
as the separator, not /
.
Upvotes: 1