Fix: Can't Delete Folder - System Mailbox Error
Encountering issues while trying to delete a folder in your email client? This article addresses a specific error related to Stalwart Labs, where users are unable to delete folders, particularly those initially created by NextCloud Mail. The error message 'TAG3 NO (NOPERM) You cannot delete system mailboxes' indicates that the system is preventing the deletion of what it considers a system-reserved mailbox. Let's dive into the details of this problem, how to reproduce it, and potential solutions or workarounds.
Background: The 'Later' Folder Dilemma
The problem arises when users who previously used NextCloud Mail find themselves with automatically created folders, such as the 'Later' folder. After discontinuing NextCloud Mail, they attempt to delete these extra folders but encounter the aforementioned error. The user in this scenario even renamed the folder to 'Also Junk' after noticing junk emails were being misdirected there. Despite the renaming, the system still identifies and treats this folder as a protected system mailbox. It's crucial to understand why this happens. Email systems often have designated folders for specific purposes, such as Inbox, Sent, Drafts, and Junk. These are typically considered system folders, and deleting them could disrupt the email client's functionality. In this case, it seems the 'Later' folder, once associated with NextCloud Mail's internal processes, has been flagged as such a system folder, preventing its deletion. Furthermore, the fact that Stalwart's junk folder is named 'Junk' in the settings, and not 'Later' or 'Also Junk', further complicates the matter, as it indicates a discrepancy between user-defined folders and system-recognized folders.
Reproducing the Issue: A Step-by-Step Guide
To reproduce this issue, follow these simple steps:
- Attempt to delete the folder (originally named 'Later', now 'Also Junk') in either Afterlogic WebMail or Firefox.
- Observe the error message:
TAG3 NO (NOPERM) You cannot delete system mailboxes.
This consistent error message confirms that the system is indeed blocking the deletion due to permission restrictions on system mailboxes. The user's attempt to delete the folder through different interfaces (Afterlogic WebMail and Firefox) suggests that the issue is not client-specific but rather a server-side restriction imposed by Stalwart Labs.
Technical Details: Version, Database, and Logs
- Version: v0.14.x
- Database: RocksDB
- Blob Storage: RocksDB
- Directory Location: Internal
- Operating System: Docker
Examining the logs provides valuable insights into the sequence of events leading to the error. Here's a snippet of the relevant log output:
2025-12-01T15:15:42Z DEBUG IMAP connection started (imap.connection-start) listenerId = "imaptls", localPort = 993, remoteIp = [REDACTED], remotePort = 42112
2025-12-01T15:15:42Z TRACE Raw IMAP input received (imap.raw-input) listenerId = "imaptls", localPort = 993, remoteIp = [REDACTED], remotePort = 42112, size = 70, contents = "TAG1 LOGIN \"[REDACTED]\" \"[REDACTED]\\r\\n"
2025-12-01T15:15:42Z TRACE Data store iteration operation (store.data-iterate) elapsed = 0ms
2025-12-01T15:15:42Z INFO Authentication successful (auth.success) listenerId = "imaptls", localPort = 993, remoteIp = [REDACTED], remotePort = 42112, accountName = "[REDACTED]", accountId = 5
2025-12-01T15:15:42Z TRACE Data store iteration operation (store.data-iterate) elapsed = 0ms
2025-12-01T15:15:42Z DEBUG Cache hit (store.cache-hit) accountId = 5, collection = "email", changeId = 247, elapsed = 0ms
2025-12-01T15:15:42Z TRACE Raw IMAP output sent (imap.raw-output) listenerId = "imaptls", localPort = 993, remoteIp = [REDACTED], remotePort = 42112, size = 397, contents = "TAG1 OK [CAPABILITY IMAP4rev2 IMAP4rev1 ENABLE SASL-IR LITERAL+ ID UTF8=ACCEPT JMAPACCESS IDLE NAMESPACE CHILDREN MULTIAPPEND BINARY UNSELECT ACL UIDPLUS ESEARCH WITHIN SEARCHRES SORT THREAD=REFERENCES LIST-EXTENDED LIST-STATUS ESORT SORT=DISPLAY SPECIAL-USE CREATE-SPECIAL-USE MOVE CONDSTORE QRESYNC UNAUTHENTICATE STATUS=SIZE OBJECTID PREVIEW QUOTA QUOTA=RES-STORAGE] Authentication successful\\r\\n"
2025-12-01T15:15:42Z TRACE Raw IMAP input received (imap.raw-input) listenerId = "imaptls", localPort = 993, remoteIp = [REDACTED], remotePort = 42112, size = 30, contents = "TAG2 UNSUBSCRIBE \"Also Junk\\r\\n"
2025-12-01T15:15:42Z TRACE Data store iteration operation (store.data-iterate) elapsed = 0ms
2025-12-01T15:15:42Z DEBUG Cache hit (store.cache-hit) accountId = 5, collection = "email", changeId = 247, elapsed = 0ms
2025-12-01T15:15:42Z TRACE Write batch operation (store.data-write) elapsed = 0ms, total = 6
2025-12-01T15:15:42Z DEBUG IMAP UNSUBSCRIBE command (imap.unsubscribe) listenerId = "imaptls", localPort = 993, remoteIp = [REDACTED], remotePort = 42112, accountId = 5, mailboxId = 2, mailboxName = "Also Junk", elapsed = 0ms
2025-12-01T15:15:42Z TRACE Raw IMAP output sent (imap.raw-output) listenerId = "imaptls", localPort = 993, remoteIp = [REDACTED], remotePort = 42112, size = 31, contents = "TAG2 OK Mailbox unsubscribed.\\r\\n"
2025-12-01T15:15:42Z TRACE Data store iteration operation (store.data-iterate) elapsed = 0ms
2025-12-01T15:15:42Z DEBUG Cache update (store.cache-update) accountId = 5, collection = "email", changeId = 248, details = [0, 1], total = [67, 8], elapsed = 0ms
2025-12-01T15:15:42Z TRACE Raw IMAP input received (imap.raw-input) listenerId = "imaptls", localPort = 993, remoteIp = [REDACTED], remotePort = 42112, size = 25, contents = "TAG3 DELETE \"Also Junk\\r\\n"
2025-12-01T15:15:42Z TRACE Data store iteration operation (store.data-iterate) elapsed = 0ms
2025-12-01T15:15:42Z DEBUG Cache hit (store.cache-hit) accountId = 5, collection = "email", changeId = 248, elapsed = 0ms
2025-12-01T15:15:42Z DEBUG IMAP error occurred (imap.error) listenerId = "imaptls", localPort = 993, remoteIp = [REDACTED], remotePort = 42112, details = "You cannot delete system mailboxes", code = "NOPERM", id = "TAG3"
2025-12-01T15:15:42Z TRACE Raw IMAP output sent (imap.raw-output) listenerId = "imaptls", localPort = 993, remoteIp = [REDACTED], remotePort = 42112, size = 53, contents = "TAG3 NO [NOPERM] You cannot delete system mailboxes\\r\\n"
2025-12-01T15:15:42Z TRACE Raw IMAP input received (imap.raw-input) listenerId = "imaptls", localPort = 993, remoteIp = [REDACTED], remotePort = 42112, size = 13, contents = "TAG4 LOGOUT\\r\\n"
2025-12-01T15:15:42Z DEBUG IMAP LOGOUT command (imap.logout) listenerId = "imaptls", localPort = 993, remoteIp = [REDACTED], remotePort = 42112, elapsed = 0ms
2025-12-01T15:15:42Z TRACE Raw IMAP output sent (imap.raw-output) listenerId = "imaptls", localPort = 993, remoteIp = [REDACTED], remotePort = 42112, size = 71, contents = "* BYE Stalwart IMAP4rev2 bids you farewell.\\r\\nTAG4 OK LOGOUT completed\\r\\n"
2025-12-01T15:15:42Z DEBUG IMAP connection ended (imap.connection-end) listenerId = "imaptls", localPort = 993, remoteIp = [REDACTED], remotePort = 42112, elapsed = 5ms
The key lines in the log are:
- `TAG2 UNSUBSCRIBE