Bugged mailboxes folder ( You are not allowed to delete Inbox, Junk or Trash folders.)

Issue Description

I have two folders without any role visible in the account panel. However those folders receives email and I cannot remove them. I have the following error: ( You are not allowed to delete Inbox, Junk or Trash folders.). How to avoid mails being sent to this folder and/or delete them? If it is bugged, can I change the behaviour in the data store? Thanks.

Expected Behavior

I can remove no role folder.

Actual Behavior

I cannot.

Reproduction Steps

  1. Create a folder test, move one email from inbox to this folder
  2. Try to delete it

Stalwart Version

v0.16.x

Installation Method

Binary (Linux)

Database Backend

MySQL

Blob Storage

MySQL

Search Engine

MySQL

Directory Backend

SQL

I have reviewed the documentation and FAQ and confirm that my issue is NOT addressed there.

on

I have searched this support forum (open and closed topics) and confirm this is not a duplicate.

on

I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.

on

The behavior is clearly hardcoded in the server source. Let me check if there’s any way to work around this via role reassignment or direct database manipulation.

Based on the source code, here is what’s happening and what you can do:

The error is by design. The server hard-codes document IDs 0 (Inbox), 1 (Trash), and 2 (Junk) as system mailboxes that can never be destroyed – the check fires before anything else and returns a CannotDestroy error. This is not a bug; it is an intentional protection for those three special-use folders.

Why do your folders appear to have “no role”? The WebUI display of a role/special-use attribute is separate from the internal document ID. A folder that was created or renamed and ended up with one of those reserved IDs (0, 1, 2) will still be protected, even if it looks like an ordinary folder in the UI. It is also possible the folders were created as duplicates (e.g. a second “Inbox”) during account setup, and while they show no role visually, their internal ID still matches a reserved slot.

What you can do:

  1. Prevent mail from arriving there – use a Sieve filter to redirect messages to a different folder before they land in that mailbox.
  2. Rename the folder – if the folder is not the real Inbox/Junk/Trash but just shares an ID, you may be able to rename it via IMAP or JMAP so mail stops flowing into it; it still cannot be deleted, but renaming is not blocked.
  3. Move all messages out and then just leave the empty folder in place – since the real Inbox/Junk/Trash must exist anyway, leaving an empty one has no operational cost.
  4. If this is truly a duplicate/ghost folder, this is a data-layer issue in MySQL. You could inspect the mailbox document table directly and verify whether there are two distinct documents sharing the same role. That would be a data-integrity problem worth reporting on this forum so a human can advise on a safe SQL-level fix.

There is no configuration knob to override the hard-coded protection for these three IDs; the guard is compiled in.

This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong.

System folders cannot be deleted. However, if the error happens when trying to delete a regular folder, try deleting it from an IMAP or JMAP client to rule out a WebUI bug.

I trier in Bulkmail but I got same errors. Maybe à bug in the store how could i remove this folder which has no rôle visible (foldertest).

Is this an account that was migrated from v0.15.x? Can you reproduce the issue from zero on a blank account?

Yes indeed. I will t’y to reproduira with new ones. How could I fix the issue now by altering the store?

The fix depends on the cause, which will be know with reproduction steps.

Bulkmail is not perfect actually, try using Betterbird or Thunderbird

I was not able to reproduce with fresh mailboxes. Folder like Inbox… cannot be changed.