Dear developers and dovecot users, I am running a dovecot with virtual users that have a mailbox using the Maildir format. mail_location = maildir:/usr/local/virtual/%d/%n New mailboxes are created on-the-fly if a new user logs in. I had the wish that the mailboxes of new users are created using the sdbox format and old mailboxes remain in Maildir format. In case the Maildir and sdbox mailboxes already exist, it is easy to use the "auto" driver which detects the correct format. But it is not possible to create mailboxes with the "auto" driver because there is no way to tell dovecot the preferred mailbox format. I wrote some lines of code which add the possibility to specify a fallback driver that will be used if a mailbox is created with the "auto" driver. mail_location = auto:/usr/local/virtual/%d/%n:FALLBACK=sdbox In case you like the idea you might want to develop it further. I am aware of the fact that there are some caveats if you mix it with other settings like LAYOUT. It won't work in any case. Best regards Bjoern --------------------------------------------------------------------------- diff -ruN src.bak/lib-storage/mail-storage.c src/lib-storage/mail-storage.c --- src/lib-storage/mail-storage.c.bak 2020-03-05 15:35:53.000000000 +0100 +++ src/lib-storage/mail-storage.c 2020-05-15 22:35:40.975992000 +0200 @@ -144,6 +144,10 @@ return classes[i]; } } + + if (set->fallback_driver != NULL) + return mail_storage_find_class(set->fallback_driver); + return NULL; } @@ -216,8 +220,10 @@ } storage_class = mail_storage_autodetect(ns, list_set); - if (storage_class != NULL) + if (storage_class != NULL) { + storage_class->v.get_list_settings(ns, list_set); return storage_class; + } (void)mail_user_get_home(ns->user, &home); if (home == NULL || *home == '\0') home = "(not set)"; diff -ruN src.bak/lib-storage/mailbox-list.c src/lib-storage/mailbox-list.c --- src/lib-storage/mailbox-list.c.bak 2020-03-05 15:35:53.000000000 +0100 +++ src/lib-storage/mailbox-list.c 2020-05-15 22:34:44.329802000 +0200 @@ -173,6 +173,8 @@ list->set.inbox_path = p_strdup(list->pool, set->inbox_path); list->set.subscription_fname p_strdup(list->pool, set->subscription_fname); + list->set.fallback_driver + p_strdup(list->pool, set->fallback_driver); list->set.list_index_fname p_strdup(list->pool, set->list_index_fname); list->set.list_index_dir @@ -360,6 +362,8 @@ else if (strcmp(key, "FULLDIRNAME") == 0) { set_r->index_control_use_maildir_name = TRUE; dest = &set_r->maildir_name; + } else if (strcmp(key, "FALLBACK") == 0) { + dest = &set_r->fallback_driver; } else if (strcmp(key, "BROKENCHAR") == 0) { if (strlen(value) != 1) { *error_r = "BROKENCHAR value must be a single character"; diff -ruN src.bak/lib-storage/mailbox-list.h src/lib-storage/mailbox-list.h --- src/lib-storage/mailbox-list.h.bak 2020-03-05 15:35:53.000000000 +0100 +++ src/lib-storage/mailbox-list.h 2020-05-15 22:35:01.251579000 +0200 @@ -121,6 +121,7 @@ const char *inbox_path; const char *subscription_fname; + const char *fallback_driver; const char *list_index_fname; /* Mailbox list index directory. NULL defaults to index directory. The path may be relative to the index directory. */ ---------------------------------------------------------------------------