IMAP folders

ZipperZapper

Verified User
Joined
Nov 30, 2015
Messages
142
I've got a problem with IMAP and I can't seem to find the right answer (or the right search term? :p).

I'm using Directadmin as my mail server, with Dovecot and Roundcube webmail. I use the IMAP-protocol to get my mail on all my devices and I keep running into a problem around folders: it's a mess.

It looks like every mailclient (Gmail on Android, Thunderbird on Windows, sometimes Windows Mail on Windows) adds its own Concepts, Sent and Trash folders to the server. At the moment one account of mine shows one inbox, 2 'Concepts'-folders, Trash, Deleted Items, Deleted Mail and INBOX.Trash, Sent, Sent Items, INBOX.Sent.

Is there a way to force every mailclient to use the same folder for sent/trash/concepts? I sometimes use Gmail over IMAP and it seems to work there, but I can't find the right place/way to set this up in Directadmin/Dovecot.
 
That was quick, thanks! Weird I didn't find that, seems logic.

It's not completely clear to me where to put it in the config. /usr/local/directadmin/custombuild/custom/dovecot/dovecot.conf? Or a seperate file? Will it automaticly apply to all currently active mailusers?
 
Better something like 90-special-folders.conf in /usr/local/directadmin/custombuild/configure/dovecot/conf.d/.

This will let you have the original version of dovecot.conf

Mailusers will or won't have new folders, depending on:

auto: Autocreate/subscribe mailbox?
  • no: Neither
  • create: Autocreate, but don't autosubscribe
  • subscribe: Autocreate and autosubscribe


They will probably need to re-read folders from the server.
 
Ah, thanks.

Won't it overwrite any already existing folders? I would like to use 'subscribe' to make sure every mailclient uses the same folders anytime, but won't have users lose their mail.

"webapps_inbox_prefix" is turned on in Custombuild, does that have any effect on the config-file? And do I have to rebuild Dovecot?

I'm sorry, don't have that much experience with Dovecot so I'm a bit scared to screw it up.
 
No need to rebuild dovecot. After re-defining special folders the current emails might get inaccessible via a regular way (it means you won't see them in new special folders). The old folders with emails won't get removed (though they might become invisible until you re-sync folders), they will become regular folders available for removing, hiding, showing, etc.

I did such an installation for my clients. So there is actually little risk, if any exists at all.

If you are unsure on consequences, you'd better test it in a dev environment. You can even use a testing server with Dovecot without Directadmin for this. If you don't have a testing server use a VPS from hosting companies which offer free-trial.
 
Thank you so much for your time. I want to make use of the default folders ''Verzonden", "Concepten", "Spam" en "Prullenbak" (Dutch). I created names that didn't exist yet, to prevent problems. I saved the following 90-special-folders.conf in /usr/local/directadmin/custombuild/configure/dovecot/conf.d/ :

namespace inbox {
prefix = INBOX.
inbox = yes

mailbox Prullenbak {
auto = subscribe
special_use = \Trash
}
mailbox Concepten {
auto = subscribe
special_use = \Drafts
}
mailbox Verzonden {
auto = subscribe
special_use = \Sent
}

mailbox Spam {
auto = subscribe
special_use = \Junk
}
}

After deleting my mailaccount and connecting to it again from Windows mailclient, I don't see any of these folders created in /home/user/Maildir or added to the subscriptions file in there. Is there a step I'm missing here? I only did a restart of the Dovecot-service.
 
Yes, you need to run:

Code:
./build dovecot_conf

My setup has these lines:

Code:
namespace {
    separator = .
    #prefix = INBOX.
    inbox = yes
    type = private
    list = yes
    subscriptions = yes

... skipped...

Then you might need to update

PHP:
$config['default_folders'] = array(...);

in /var/www/html/roundcube/config/config.inc.php and save it to /usr/local/directadmin/custombuild/custom/roundcube/config.inc.php
 
Last edited:
I'm completely lost now. The 90-special-folders.conf did not seem to work, maybe because I already had a custom Dovecot config file, so I added it to that file:

namespace inbox {
prefix = INBOX.
separator = .
inbox = yes
type = private
list = yes
subscriptions = yes

mailbox Prullenbak {
auto = subscribe
special_use = \Trash
}
mailbox Concepten {
auto = subscribe
special_use = \Drafts
}
mailbox Verzonden {
auto = subscribe
special_use = \Sent
}

mailbox Spam {
auto = subscribe
special_use = \Junk
}
}

Then I used https://help.directadmin.com/item.php?id=228 to create default folders for new users:

#!/bin/sh
DIR=/home/$username/imap/$domain/$user/Maildir
mkdir -p $DIR/.INBOX.Concepten
mkdir -p $DIR/.INBOX.Verzonden
mkdir -p $DIR/.INBOX.Prullenbak
echo ".INBOX.Concepten" >> $DIR/subscriptions
echo ".INBOX.Verzonden" >> $DIR/subscriptions
echo ".INBOX.Prullenbak" >> $DIR/subscriptions
chown -R $username:mail $DIR
exit 0;

And in /usr/local/directadmin/custombuild/custom/roundcube/config.inc.php I changed the values to my new folder names and turned 'create_default_folders' to false.

$config['drafts_mbox'] = 'INBOX.Concepten';
$config['junk_mbox'] = 'INBOX.Spam';
$config['sent_mbox'] = 'INBOX.Verzonden';
$config['trash_mbox'] = 'INBOX.Prullenbak';
$config['default_folders'] = array('INBOX', 'INBOX.Concepten', 'INBOX.Verzonden', 'INBOX.Spam', 'INBOX.Prullenbak');
$config['smtp_helo_host'] = 'xxxxxxxxxxx';
$config['smtp_auth_type'] = 'LOGIN';
$config['create_default_folders'] = false;
$config['protect_default_folders'] = true;
$config['login_autocomplete'] = 2;
$config['quota_zero_as_unlimited'] = true;
$config['enable_spellcheck'] = false;
$config['email_dns_check'] = true;
$config['mime_types'] = '/var/www/html/roundcube/config/mime.types';

If I create a new mailuser under a domain now, the folders 'INBOX.Concepten', 'INBOX.Verzonden', 'INBOX.Spam' and 'INBOX.Prullenbak' are created in Maildir, which I would expect from the email_create_post.sh.

But AS SOON as I login that new mailbox with Roundcube, '.Verzonden', '.Prullenbak', '.Spam' and '.Concepten' are also creatied in Maildir and added to the subscriptions file.

What is going wrong? I did a rebuild of the Dovecot-config and a rebuild of Roundcube after every change I made.
 
Last edited:
Alex, so much thanks for your help. I deleted the email_create_post.sh and now use the following settings:

dovecot.conf
Code:
namespace inbox {
  inbox = yes
  separator = .
  type = private
  list = yes
  subscriptions = yes

  mailbox Concepten {
    auto = subscribe
    special_use = \Drafts
  }
  mailbox Prullenbak {
    auto = subscribe
    special_use = \Trash
  }
  mailbox Verzonden {
    auto = subscribe
    special_use = \Sent
  }

  mailbox INBOX.spam {
    auto = subscribe
    special_use = \Junk
  }
}

Roundcube config
Code:
$config['drafts_mbox'] = '.Concepten';
$config['trash_mbox'] = '.Prullenbak';
$config['sent_mbox'] = '.Verzonden';
$config['junk_mbox'] = '.INBOX.spam';
$config['default_folders'] = array('INBOX', '.Concepten', '.Prullenbak', '.Verzonden', '.INBOX.spam');

Now when I create a new mailaccount and login to Roundcube, the right folders are created and registered, so it seems to work. Apart from one thing: I can't delete files. Roundcube gives me this error:

UID MOVE: Invalid mailbox name: Begins with hierarchy separator

Weird? I tried switching around the order in 'default_folders' and adding/deleting the 'seperator = .' statement in dovecot (what does it do exactly? Doesn't seem to make any difference?), and I always end up with one folder giving me that error. Trash or Drafts mostly.

The subscriptions file seems right to me, the right folders exist in the Maildir. Puzzled.
 
I believe the roundcube config should be modified on your side. I see these in defaults.inc.php:

PHP:
$config['drafts_mbox'] = 'Drafts';
$config['junk_mbox'] = 'Junk';
$config['sent_mbox'] = 'Sent';
$config['trash_mbox'] = 'Trash';

no leading dots in the folders' names.
 
Thanks Alex, it works!

One thing though: everything works as expected when creating a new account. the folders are created and used by Roundcube and other mail clients.

I also tried to make it work for my already existing account too, so I deleted the old ".INBOX.Sent Items" and others from Maildir and from the subscriptions-file.

After logging in with Roundcube I see the new folders are created and added to subscriptions, but after sending/deleting a mail as test, I see the old folders appear again too and Roundcube gets confused about the folder-tree.

Is there a way I have to 'reset' any existing account to make it work? Without deleting the mail inside it, if possible (I moved the things I like to keep to a temporary folder with a different name).
 
The issue happened when you tried to delete emails in Roundcube? Try and check then your preferences in Roundcube, as it allows to re-define special folders per email-account in its interface.
 
Good. The other user might need to reset the settings in Roundcube too. Probably it can be changed in MySQL DB directly or in phpmyadmin. I did not study this moment yet.
 
Good. The other user might need to reset the settings in Roundcube too. Probably it can be changed in MySQL DB directly or in phpmyadmin. I did not study this moment yet.

This has been very helpful indeed!!!. Will adding \Trash folders this way also mean they get purged as such when the option to Auto Purge Emails is set in the Administrator Settings ?

I know this thread is a bit older, but can't find anything to solve the auto purge of trash folders other than starting with the above.

Cheers,

Ray
 
Hello dear friend @zEitEr ,

Please if you can take a look at my thread in detail issues. Thanks in advance!

 
Back
Top