#980·openship

[Bug]: Webmail "Move to spam" only adds a SPAM keyword, never moves the message to Junk

Author: samueljansemCreated Sep 28, 2026Updated Sep 28, 2026

Existing issue

  • I have searched the existing issues and found no duplicate.

Problem description

In webmail, Move to spam doesn't move the message. It disappears, then comes back in the inbox on the next refresh, and the Junk folder stays empty.

The client sends Gmail-style labels (addLabels: ["SPAM"], removeLabels: ["INBOX"]), but modifyLabels in apps/email/server/src/lib/imap-driver.ts stores them as IMAP flags instead of moving the message:

typescript
await client.messageFlagsAdd(found, input.addLabels, { uid: true });    // adds keyword "SPAM"
await client.messageFlagsRemove(found, input.removeLabels, { uid: true }); // "INBOX" flag: no-op

The message stays in INBOX with a literal SPAM keyword, and the API returns ok: true.

The same path affects Archive and Move to inbox. Delete works because deleteThreads really moves the message.

Expected: System labels map to mailbox moves (SPAM → Junk, TRASH → Trash, removing INBOX → Archive), and only other labels are stored as flags.

Steps to reproduce

  1. Open webmail and select a message in the inbox.
  2. Choose Move to spam.
  3. Refresh. The message is back in the inbox, and Spam is empty.
  4. On the mail server: doveadm fetch -u <user> flags mailbox INBOX KEYWORD SPAM shows the message with \Seen SPAM.

Environment

  • OpenShip version/commit: openship-webmail v0.8.0 (234d8a9), openship-mail 0.7.2; modifyLabels is unchanged on main
  • Deployment method: Docker (self-hosted)
  • Operating system: Linux
  • Browser (if applicable): any

Additional context

Archive is auto = no in the Dovecot config, so an archive move needs to create the mailbox if it doesn't exist.