matcha icon indicating copy to clipboard operation
matcha copied to clipboard

Saving to Sent fails on non-English Exchange/Office 365 (APPEND uses a hardcoded folder name instead of the \Sent special-use attribute)

Open Robin-Everaars opened this issue 5 months ago • 2 comments

Same three accounts as in #1426: Gmail, Proton (via Proton Mail Bridge, custom IMAP), and an Exchange Online / Office 365 account. Sending works everywhere, but on the Office 365 account matcha can't save the sent copy. Accepting or declining a calendar invite goes out fine, then this shows up:

2026/07/02 10:21:03 Failed to append RSVP to Sent folder: imap: NO [TRYCREATE] Folder is not found.
                                                             RSVP sent: ACCEPTED

The reply itself is delivered (RSVP sent: ACCEPTED), it's only the APPEND to Sent that fails.

The name matcha appends to comes from a hardcoded table in fetcher/fetcher.go:

func getSentMailbox(account *config.Account) string {
	switch account.ServiceProvider {
	case config.ProviderGmail:
		return "[Gmail]/Sent Mail"
	case "outlook":
		return "Sent Items"
	case "icloud":
		return "Sent Messages"
	default:
		return "Sent"
	}
}

and AppendToSentMailbox uses that string directly, without asking the server what the Sent folder is actually called:

sentMailbox := getSentMailbox(account)
appendCmd := c.Append(sentMailbox, ...)

The catch is that Exchange localizes the special folder names to the mailbox language. My Office 365 mailbox is Dutch, so the Sent folder isn't "Sent Items", it's "Verzonden items". "Sent Items" doesn't exist, so the APPEND comes back NO [TRYCREATE]. The same thing would hit French ("Éléments envoyés"), German ("Gesendete Elemente"), and so on, plus any custom IMAP account whose Sent folder isn't literally named "Sent".

Same shape as #1426, really: matcha assumes a name instead of asking the server for it. And the fix is already sitting in the same file. getMailboxByAttr looks a mailbox up by its RFC 6154 special-use attribute, and the Trash path already uses it, falling back to the hardcoded name only if the lookup fails:

trashMailbox, err := getMailboxByAttr(c, imap.MailboxAttrTrash)
if err != nil {
	trashMailbox = getTrashMailbox(account)
}

AppendToSentMailbox just never got the same treatment. Doing the same with \Sent finds the real folder whatever the language:

sentMailbox, err := getMailboxByAttr(c, imap.MailboxAttrSent)
if err != nil {
	sentMailbox = getSentMailbox(account)
}

That covers the RSVP path and the normal send path in one place (both go through AppendToSentMailbox), and ArchiveSentEmail has the same blind spot since it also calls getSentMailbox. The send succeeds either way, so it's easy to miss, the copy just quietly never shows up in Sent.

To reproduce: add an Exchange / Office 365 account whose mailbox language isn't English (or any custom IMAP account whose Sent folder isn't named "Sent") and send something, or RSVP to an invite.

I can test a fix across all three accounts like I did for #1426.

Version: matcha 0.43.0, go-imap v2, Linux.

Robin-Everaars avatar Jul 02 '26 08:07 Robin-Everaars

Should be fixed in #1643

@Robin-Everaars, please, check out the binaries here!

andrinoff avatar Jul 04 '26 20:07 andrinoff

I can confirm the fix in PR #1643 works correctly on my M365 account! AppendToSentMailbox now dynamically retrieves the correct Sent folder via the \Sent attribute instead of throwing the folder not found error. Thanks for the quick fix!

Robin-Everaars avatar Jul 06 '26 08:07 Robin-Everaars