Skip to content

fix(outbox): send even when no sent mailbox is configured - #13663

Open
tareko wants to merge 2 commits into
nextcloud:mainfrom
tareko:fix/send-without-sent-mailbox
Open

tareko wants to merge 2 commits into
nextcloud:mainfrom
tareko:fix/send-without-sent-mailbox

Conversation

@tareko

@tareko tareko commented Sep 9, 2026

Copy link
Copy Markdown

Note: Assisted by GLM 5.3.

Problem

When an account has no sent mailbox configured (sent_mailbox_id is NULL — e.g. the IMAP server does not advertise special-use folders and the folder was never mapped), SentMailboxHandler aborts the send chain before the SMTP submission. The message strands in the outbox indefinitely with STATUS_NO_SENT_MAILBOX, while the UI first shows "message sent" and then an error a few seconds later.

Decision

There are two paths to addressing this: The first is to automatically generate some default folders like "Sent" - I felt this required a wider discussion. Instead, I chose to just allow the send and log a warning.

Changes

  • SentMailboxHandler no longer blocks the chain: it logs a warning and continues, so the message is actually sent.
  • CopySentMessageHandler already handles the missing-sent-mailbox case after the SMTP send, marking the message STATUS_IMAP_SENT_MAILBOX_FAIL, which the API surfaces as 202 "sent, copying will be retried".
  • STATUS_NO_SENT_MAILBOX stays defined and mapped in MessageApiController for rows written by older versions.
  • Updated SentMailboxHandlerTest to assert the chain continues and no status is set pre-send.

Testing

  • tests/Unit/Send/ — 21 tests, 82 assertions ✅
  • tests/Unit/Service/OutboxServiceTest.php — 14 tests ✅
  • tests/Unit/Controller/MessageApiControllerTest.php — 19 tests ✅
  • composer cs:check
  • Psalm not runnable locally (PHP 8.5 vs ^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0); left to CI

Fixes #10546
Fixes #4153

SentMailboxHandler aborted the send chain before the SMTP submission
when the account had no sent mailbox mapped, so messages stranded in
the outbox indefinitely with STATUS_NO_SENT_MAILBOX while the UI first
reported success and then failure. Post-send handling of a missing
sent mailbox already exists in CopySentMessageHandler, which marks the
message STATUS_IMAP_SENT_MAILBOX_FAIL after the message went out.

STATUS_NO_SENT_MAILBOX stays defined and mapped in the API for rows
written by older versions.

Fixes nextcloud#10546
Fixes nextcloud#4153

Assisted-by: DeepSeek-Harness:glm-5.3
Signed-off-by: Tarek Loubani <tarek@tarek.org>
@kesselb

kesselb commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Why would you keep SentMailboxHandler if it's basically a no-op?

Assisted-by: DeepSeek-Harness:glm-5.3
Signed-off-by: Tarek Loubani <tarek@tarek.org>
@tareko
tareko force-pushed the fix/send-without-sent-mailbox branch from ce10e9e to bf5bf7a Compare September 10, 2026 18:23
@tareko

tareko commented Sep 10, 2026

Copy link
Copy Markdown
Author

Good point. Thank you and removed. SentMailboxHandler is deleted and the chain now starts at AntiAbuseHandler; CopySentMessageHandler owns the missing-sent-mailbox semantics after the send. Its existing warning now includes the account id. Pushed as a fixup commit.

@kesselb kesselb self-assigned this Sep 14, 2026
@kesselb kesselb added bug 3. to review AI assisted This PR contains AI-assisted commits labels Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review AI assisted This PR contains AI-assisted commits bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sending an email is not possible if a sent mailbox is not configured "No sent mailbox configured" Error when sending a message

2 participants