Problem with renaming Junk folder

Your question

I recently renamed the Junk folder to Spam using the Stalwart web ui (keeping the role “Junk”). But Thunderbird doesn’t seem to accept that and keeps creating it’s own Junk folder. Closing Thunderbird and deleting this newly created Junk folder results in this error message after restarting TBird:

The current operation in “Spam” failed. The server for the “Stalwart” account responded: [NONEXISTENT] Mailbox does not exist.

And it then creates the folder again.

In the Thunderbird settings I chose that it shall use the “Spam” folder from the Stalwart-server (not using a custom folder).

Am I doing something wrong? Can anyone confirm this behaviour?

Stalwart: 0.16.9 (Podman)
Thunderbird. 151.0.1

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 key here is the aliases field on special-use folder definitions. When you renamed your Junk folder to “Spam” in the WebUI, Thunderbird still tries to SELECT/APPEND to a folder literally named “Junk” (because it has its own hard-coded Junk folder name). The server then rejects that because no mailbox called “Junk” exists anymore.

The fix is to add "Junk" (and any other names Thunderbird might try) as an alias for your “Spam” folder. This is done via the defaultFolders setting on the Email singleton (WebUI: Settings › Email › Defaults), using the aliases field:

{
  "defaultFolders": {
    "junk": {
      "name": "Spam",
      "create": true,
      "subscribe": true,
      "aliases": ["Junk", "Junk Mail", "Junk E-mail"]
    }
  }
}

With aliases in place, any IMAP command Thunderbird issues against the old “Junk” name will be transparently resolved to your “Spam” folder, so Thunderbird won’t keep recreating it.

Note: The aliases field affects the server-wide default for new accounts. For an existing account whose folder was already renamed, the alias may need to be set at the individual mailbox level if the per-user folder config differs from the default. If the problem persists after updating the default, a human community member can advise on editing per-user mailbox settings.

See the IMAP and POP3 - Default folders documentation for details.

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

Server side this is fine, renaming the folder while keeping the Junk role means it still reports the \Junk special-use flag over IMAP, so nothing was lost. The recreation is Thunderbird, which doesn’t always follow the server’s \Junk flag and instead recreates a literal “Junk” from its own account settings; the [NONEXISTENT] error is TB trying to act on a folder name that no longer exists on the server.

Fix it in Thunderbird’s per-account Junk settings: point the junk destination explicitly at the renamed “Spam” folder, and clear any setting that moves junk to a folder named “Junk”. Then delete TB’s auto-created Junk folder and restart. If it still recreates it, send me an IMAP LIST with RETURN (SPECIAL-USE) so I can confirm \Junk is on the Spam folder.