Skip to content

fix no sent mailbox configured#8311

Open
hamza221 wants to merge 10 commits intomainfrom
bug/not-sent-mailbox
Open

fix no sent mailbox configured#8311
hamza221 wants to merge 10 commits intomainfrom
bug/not-sent-mailbox

Conversation

@hamza221
Copy link
Contributor

@hamza221 hamza221 commented Mar 28, 2023

Fix #4153
Repro:

  1. remove the default folder for sent ("you can do it in vuex by setting sentMailboxId to null")
  2. Try to send a message

Fix:
Ps: Other ideas are appreciated

  1. Check if a mailbox named Sent or equivalent in the local language
  • if it exists set it as Sent default folder and resend message, if not:
  1. create a new mailbox
  2. set it as send default folder
  3. resend the message
  4. Catch exceptions and inform the user with toasts accordingly

@JohannesGGE
Copy link
Contributor

Where exactly do you set sentMailboxId to null? (I can't get the error reproduced)

@hamza221
Copy link
Contributor Author

hamza221 commented Jul 19, 2023

Where exactly do you set sentMailboxId to null? (I can't get the error reproduced)

I do it in the vue.js devtools browser extension

Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes feel a bit too complex and messy. I think we should try to find a cleaner, less complicated spot to place the logic. I'll think about an alternative.

@ChristophWurst
Copy link
Member

The changes feel a bit too complex and messy. I think we should try to find a cleaner, less complicated spot to place the logic. I'll think about an alternative.

How about we just move the logic into the head of NewMessageModal::onSend? We have access to the accountId and can fetch the account, check for the mailbox existence and act, then proceed with the usual send logic.

The good news is that this isn't too far off the current state. The code just has to be pushed around a bit.

I also think we don't necessarily need a special loading text for this state. For the user it's sufficient if we show Sending … while creating/assigning the mailbox

@ChristophWurst ChristophWurst mentioned this pull request Nov 29, 2023
24 tasks
@hamza221 hamza221 marked this pull request as draft March 4, 2025 14:00
@hamza221 hamza221 force-pushed the bug/not-sent-mailbox branch 2 times, most recently from 3913ba7 to 40f8232 Compare March 7, 2025 16:37
@hamza221 hamza221 requested a review from ChristophWurst March 7, 2025 16:38
@hamza221 hamza221 marked this pull request as ready for review March 7, 2025 16:38
@hamza221 hamza221 requested a review from kesselb as a code owner March 7, 2025 16:38
Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logical flow looks good otherwise

@hamza221 hamza221 force-pushed the bug/not-sent-mailbox branch from 3201810 to 89aaf43 Compare March 16, 2025 18:39
Signed-off-by: hamza221 <hamzamahjoubi221@gmail.com>
@hamza221 hamza221 force-pushed the bug/not-sent-mailbox branch from 89aaf43 to 3503feb Compare March 16, 2025 18:40
Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No test coverage

Signed-off-by: Hamza Mahjoubi <hamzamahjoubi221@gmail.com>
@hamza221 hamza221 marked this pull request as ready for review March 17, 2025 15:38
Signed-off-by: Hamza Mahjoubi <hamzamahjoubi221@gmail.com>
@hamza221 hamza221 marked this pull request as draft March 17, 2025 18:16
Signed-off-by: Hamza Mahjoubi <hamzamahjoubi221@gmail.com>
@hamza221 hamza221 marked this pull request as ready for review March 17, 2025 18:19
@ChristophWurst
Copy link
Member

Works, but not as expected.

Bildschirmfoto vom 2025-05-16 13-28-28

I see this chain of toasts, so the logic kicks in.

Bildschirmfoto vom 2025-05-16 13-29-15

But my sent mailbox is now set to nullSent. Which is not just a UI glitch, it created this mailbox:

image

The creation shouldn't even happen, because I do have a mailbox named Sent and it does have the \sent attribute:

image

Signed-off-by: Hamza <hamzamahjoubi221@gmail.com>
@hamza221 hamza221 requested a review from ChristophWurst May 24, 2025 16:25
@ChristophWurst
Copy link
Member

It fails to detect my existing mailbox Sent and runs into a HTTP400. The toasts are honestly overwhelming and confusing.

First I get this
Bildschirmfoto vom 2025-05-27 09-52-22

Bildschirmfoto vom 2025-05-27 09-52-25

image

The message is sent and stored in my mailbox called "Sent", nevertheless?!

@hamza221
Copy link
Contributor Author

hamza221 commented Jun 5, 2025

It fails to detect my existing mailbox Sent and runs into a HTTP400. The toasts are honestly overwhelming and confusing.

First I get this Bildschirmfoto vom 2025-05-27 09-52-22

Bildschirmfoto vom 2025-05-27 09-52-25

image

The message is sent and stored in my mailbox called "Sent", nevertheless?!

Toasts were all over the place,
It should make sense now, I added early returns and removed extra Toasts

/**
* @param Account $account
* @param string $name
* @param array<Horde_Imap_Client::SPECIAL_USE_*> $specialUseAttributes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ see Psalm. Missing an import

Comment on lines +307 to +309
logger.info(`creating ${t('mail', 'Sent')} mailbox`)
try {
const newSentMailbox = await this.mainStore.createMailbox({ account, name: (account.personalNamespace ?? '') + t('mail', 'Sent'), specialUseAttributes: ['\\Sent'] })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extract new mailbox name into a variable for code readability and to have the actual mailbox name logged, not just the translation

try {
await this.setSentMailboxAndResend(account, sentMailboxId, data)
showSuccess(t('mail', 'Default sent folder set'))
this.onSend(data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing await


try {
await this.setSentMailboxAndResend(account, newSentMailboxId, data)
this.onSend(data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing await

async onSend(data, force = false) {
const account = this.mainStore.getAccount(data.accountId)
if (!account?.sentMailboxId) {
this.onNewSentMailbox(data, account)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing await

const sentMailboxId = mailboxes.find((mailbox) => (mailbox.name === (account.personalNamespace ?? '') + 'Sent') || (mailbox.name === (account.personalNamespace ?? '') + t('mail', 'Sent')))?.databaseId
if (sentMailboxId) {
try {
await this.setSentMailboxAndResend(account, sentMailboxId, data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the method takes to params. data is superfluous

}
logger.info(`creating ${t('mail', 'Sent')} mailbox`)
try {
const newSentMailbox = await this.mainStore.createMailbox({ account, name: (account.personalNamespace ?? '') + t('mail', 'Sent'), specialUseAttributes: ['\\Sent'] })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createMailbox prepends the namespace too. This can lead to double namespacing.

@kesselb
Copy link
Contributor

kesselb commented Feb 25, 2026

The changes for the backend, to create a mailbox with special usage, are in since #11889.

What do you think of implementing everything in the backend, like for the drafts? If there's no sent mailbox, we will just create one in transmission service. I think that makes everything a bit simpler.

@hamza221
Copy link
Contributor Author

hamza221 commented Mar 12, 2026

Fix #4153

I created a draft here #12555 , way simpler as you assumed but I'm not sure how to test it yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"No sent mailbox configured" Error when sending a message

4 participants