From 0359bb1b871793dc8b7d610108ae1dfea4460941 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Tue, 24 Feb 2026 11:26:35 +0100 Subject: [PATCH 1/2] Do not load message from Drafts folder when replying. fix #3939 --- .../src/components/webmail/ComposeEmailForm.vue | 13 ++++++++++--- frontend/src/constants.json | 3 ++- frontend/src/views/webmail/EmailView.vue | 3 ++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/webmail/ComposeEmailForm.vue b/frontend/src/components/webmail/ComposeEmailForm.vue index cc483b04f..bc16e809a 100644 --- a/frontend/src/components/webmail/ComposeEmailForm.vue +++ b/frontend/src/components/webmail/ComposeEmailForm.vue @@ -202,6 +202,7 @@ import { ref, watch } from 'vue' import { useRoute, useRouter } from 'vue-router' import { useGettext } from 'vue3-gettext' import { useAuthStore, useBusStore } from '@/stores' +import constants from '@/constants.json' import debounce from 'debounce' import AttachmentsDialog from '@/components/webmail/AttachmentsDialog' import BodyEditor from '@/components/webmail/BodyEditor' @@ -356,9 +357,12 @@ const lookForContacts = debounce(async (search) => { }, 500) const initialize = async (body) => { - if (route.query.mailid) { + if (route.params.mailbox === constants.DRAFTS_FOLDER && route.query.mailid) { // Load draft - const draft = await api.getEmailContent('Drafts', route.query.mailid) + const draft = await api.getEmailContent( + constants.DRAFTS_FOLDER, + route.query.mailid + ) form.value.sender = draft.data.from_address.address if (draft.data.to?.length) { form.value.to = draft.data.to.map((rcpt) => rcpt.address) @@ -430,7 +434,10 @@ watch( ) if (!route.query.uid) { - api.createComposeSession(route.query.mailid).then((resp) => { + const args = + route.query.mailbox === constants.DRAFTS_FOLDER ? [route.query.mailid] : [] + console.log(args) + api.createComposeSession(...args).then((resp) => { const query = { ...route.query, uid: resp.data.uid } attachmentCount.value = resp.data.attachments?.length || 0 router.push({ name: route.name, query }) diff --git a/frontend/src/constants.json b/frontend/src/constants.json index 7b4066720..63bc3bfba 100644 --- a/frontend/src/constants.json +++ b/frontend/src/constants.json @@ -4,5 +4,6 @@ "SUPER_ADMIN": "SuperAdmins", "RESELLER": "Resellers", "DOMAIN_ADMIN": "DomainAdmins", - "USER": "SimpleUsers" + "USER": "SimpleUsers", + "DRAFTS_FOLDER": "Drafts" } diff --git a/frontend/src/views/webmail/EmailView.vue b/frontend/src/views/webmail/EmailView.vue index 0281bcc3a..2bbc58675 100644 --- a/frontend/src/views/webmail/EmailView.vue +++ b/frontend/src/views/webmail/EmailView.vue @@ -54,7 +54,7 @@ > Date: Tue, 24 Feb 2026 11:37:14 +0100 Subject: [PATCH 2/2] Better error message. --- frontend/src/components/webmail/ComposeEmailForm.vue | 1 - modoboa/webmail/lib/imaputils.py | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/webmail/ComposeEmailForm.vue b/frontend/src/components/webmail/ComposeEmailForm.vue index bc16e809a..606c91b66 100644 --- a/frontend/src/components/webmail/ComposeEmailForm.vue +++ b/frontend/src/components/webmail/ComposeEmailForm.vue @@ -436,7 +436,6 @@ watch( if (!route.query.uid) { const args = route.query.mailbox === constants.DRAFTS_FOLDER ? [route.query.mailid] : [] - console.log(args) api.createComposeSession(...args).then((resp) => { const query = { ...route.query, uid: resp.data.uid } attachmentCount.value = resp.data.attachments?.length || 0 diff --git a/modoboa/webmail/lib/imaputils.py b/modoboa/webmail/lib/imaputils.py index 1028471e4..d40356659 100644 --- a/modoboa/webmail/lib/imaputils.py +++ b/modoboa/webmail/lib/imaputils.py @@ -783,6 +783,8 @@ class IMAPconnector: bcmd = "BODY.PEEK" if readonly else "BODY" to_fetch = f"(BODYSTRUCTURE {bcmd}[HEADER.FIELDS ({what})])" data = self._cmd("FETCH", mailid, to_fetch) + if int(mailid) not in data: + raise ImapError(f"Message with UID {mailid} not found in {mbox} folder") return data[int(mailid)]