Add Default Mailbox Folders (Sent, Drafts Trash, Junk, Archive) to Dovecot

Here is a fix I cooked up. By default, iOS Mail would not auto generate the correct folders and you would also be required to manually map to them in the iOS Settings. Another issue was Windows 10 Mail creating its own separate folder for sent emails called “Sent Items” which is now fixed as well since all sent emails regardless of client go into the “Sent Items” folder. So now, besides with Rainloop, email folder mappings work perfectly with iOS Mail and Windows 10 Mail and likely almost any other normal email client out there.

Note, though, that unless you know what you are doing, you will want to do this on a fresh install before logging in with any email accounts especially if you are using the built-in Rainloop webmail. Otherwise, Rainloop will map to the wrong folder locations for that login user and you will then have to clear some SQL database entries and Rainloop’s cached files in its data folder from the backend (highly discouraged!). So only proceed if you are starting with a fresh install of CyberPanel, skipping the next paragraph and starting with step 5.

But if you are not using the built-in Rainloop webmail, you can easily start with what you need from a fresh installation by doing the following:

Step 1. Delete all email accounts within CyberPanel
Step 2. Deleting all remnants of old emails within the vmail folder under the Home directory.
Step 3. You also delete any manually installed webmail clients (such as a non-stock Rainloop install or RoundCube) from their public_html directories .Step 4. Delete their respective databases. Once finished, proceed to the fifth and final step.

Step 5. Replace the namespace section in dovecot.conf under /etc/dovecot with the following and then restart the dovecot service (service dovecot restart):

namespace inbox {
inbox = yes
location =
prefix =
mailbox “Deleted Items” {
auto = create
special_use = \Trash
}
mailbox “Drafts” {
auto = create
special_use = \Drafts
}
mailbox “Archive” {
auto = create
special_use = \Archive
}
mailbox “Sent Items” {
auto = create
special_use = \Sent
}
mailbox “Junk Mail” {
auto = create
special_use = \Junk
}
}

Thanks for this.
@Hifihedgehog

been looking into this is there a safe way to upgrade/migrate namespaces? I was wondering if this is something we can script in a future cyberpanel update to switch to the auto from the autocreate so everyone has good defaults going forward. We could then standardize this and then enable global sieve for the Spam/Junk/Junk E-Mail folders.

I was looking at the competition config files for reference.

c panel dovecot template

c panel dovecot conf

Is there a way to extend the folders from the default namespace one vs defining an entirely new namespace?

default dovecot namespace

namespace {
type = private
separator = .
prefix = INBOX.
inbox = yes
}

Notice the default Junk/Spam folder created by Rainloop upon login is this one.
INBOX.Junk E-mail

=================

See also the latest dovecote recommendations.
https://doc.dovecot.org/configuration_manual/namespace/

======================

I found this really nice one and modified it so that your folders are also mapped to the same one.

It looks like the below might be a silver bullet that works everywhere.

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

mailbox Drafts {
special_use = \Drafts
auto = subscribe
}

mailbox Junk {
special_use = \Junk
auto = create
}

mailbox “Junk Mail” {
special_use = \Junk
auto = no
}

mailbox “Junk E-mail” {
special_use = \Junk
auto = no
}

mailbox spam {
special_use = \Junk
auto = no
}

mailbox Spam {
special_use = \Junk
auto = no
}

mailbox Trash {
special_use = \Trash
auto = subscribe
}

mailbox Sent {
special_use = \Sent
auto = subscribe
}

mailbox “Sent Mail” {
special_use = \Sent
auto = no
}

mailbox “Sent Messages” {
special_use = \Sent
auto = no
}

mailbox Archive {
special_use = \Archive
auto = create
}

mailbox “Archives” {
special_use = \Archive
auto = no
}
}

Which one is working and up to date?

Are you stating that the email namespace has been updated in CyberPanel to avoid folder duplication across different email clients?