Setup IMAP folders.

bdacus01

Verified User
Joined
Jul 22, 2017
Messages
528
Location
Murfreesboro
All:

This was born out of these 2 posts.

https://forum.directadmin.com/showthread.php?t=54713
and
http://forum.directadmin.com/showthread.php?t=58403

Its a general How to get IMAP folders working based on the general structure of

Inbox
Sent
Drafts
Junk
Trash
Archive

Some general Notes to start.

First adding anything to these two file locations doesn't do anything I see.
Code:
/usr/local/directadmin/custombuild/configure/dovecot/conf.d/
or
Code:
/usr/local/directadmin/custombuild/custom/dovecot/conf.d/
In general with the stock install of DA you get folders like

INBOX
INBOX.spam < We don't want this
Sent
Drafts
Junk
Trash

We want every mail client to get and use the same structure of folders. We want them to auto create and auto subscribe.

Like this.

Inbox
Sent
Drafts
Junk
Trash
Archive

To do this you need a feature and 90-special-folders.conf.. I took hours to hunt it down (since the directadmin.conf is not centrally documented)

It's here https://www.directadmin.com/features.php?id=1679

MAKE SURE YOU HAVE A BACKUP of all your sites and email. Before trying this.

new directadmin.conf option, internal default to:
spam_inbox_prefix=1 < this is the issue. If it's set to 1 or not in the directadmin.conf it defaults to 1 = INBOX.spam


if you set it to 0, all areas in DA will use "Junk" instead of INBOX.spam for paths. < Here it is we want "Junk".

Set spam_inbox_prefix=0 in directadmin.conf

Code:
cd /usr/local/directadmin 
echo spam_inbox_prefix=0 >> conf/directadmin.conf
systemctl restart directadmin 
cd custombuild
./build update
./build set webapps_inbox_prefix no
./build roundcube
cd ..
# This will rebuild all of your CURRENT EMAIL FOLDERS...  YOU BACKED UP CORRECT????  Note: I didn't lose a thing.
echo "action=convert&value=imap_inbox_prefix" >> data/task.queue; ./dataskq d2000
echo "action=rewrite&value=filter" >> data/task.queue; ./dataskq d2000
Now you will have Junk created instead of INBOX.Spam. (Note: Junk is RFC compliant https://tools.ietf.org/html/rfc6154)

Then you have to go to

Code:
cd /etc/dovecot/conf.d
nano 90-special-folders.conf
Paste below in the blank file(this worked for me)

Code:
namespace inbox {
  type = private
  separator = .
  subscriptions = yes
  inbox = yes
}
namespace inbox {
  mailbox Drafts {
    auto = subscribe
    special_use = \Drafts
  }
  mailbox Junk {
   auto = subscribe
   special_use = \Junk
 }
 mailbox Archive {
   auto = subscribe
   special_use = \Archive
 }
 mailbox Trash {
   auto = subscribe
   special_use = \Trash
 }
 mailbox Sent {
   auto = subscribe
   special_use = \Sent
 }
}
You can confirm it took by doing

Code:
cd /usr/local/directadmin/custombuild 
./build dovecot_conf
dovecot -n
Then copy /var/www/html/roundcube/config/config.inc.php to /usr/local/directadmin/custombuild/custom/roundcube/config.inc.php

might need to create Roundcube folder.
Code:
mkdir /usr/local/directadmin/custombuild/custom/roundcube/
Code:
cp /var/www/html/roundcube/config/config.inc.php /usr/local/directadmin/custombuild/custom/roundcube/config.inc.php
find the general section with entries below and set or add to as such:

Code:
$config['drafts_mbox'] = 'Drafts';
$config['junk_mbox'] = 'Junk';
$config['sent_mbox'] = 'Sent';
$config['trash_mbox'] = 'Trash';
$config['default_folders'] = array('INBOX', 'Drafts', 'Archive', 'Sent', 'Junk', 'Trash');
$config['create_default_folders'] = true;
$config['protect_default_folders'] = true;
then

Code:
cd /usr/local/directadmin/custombuild
./build roundcube
./build dovecot_conf
Now go test with an account. make sure you login.

This should give you the structure noted at the beginning.

Hope this helps. Report success or issues as needed.
 
Last edited:
Top