stalwartlabs / mail-server

Secure & Modern All-in-One Mail Server (IMAP, JMAP, POP3, SMTP)
https://stalw.art
5.25k stars 221 forks source link

[enhancement]: implement special_use directory mapping #458

Closed mightyBroccoli closed 5 months ago

mightyBroccoli commented 5 months ago

Which feature or improvement would you like to request?

With dovecot it is possible to map multiple directory folders (Sent , Sent Objects, Gesendet ) to a single directory /Sent within the mailbox. https://doc.dovecot.org/configuration_manual/namespace/#core_setting-namespace/mailbox/special_use https://github.com/mailcow/mailcow-dockerized/blob/master/data/conf/dovecot/dovecot.folders.conf

Due to many clients having multiple defaults in which mailbox dir for example, sent items are stored.

Is your feature request related to a problem?

Kind of, while testing I noticed that Outlook / Thunderbird / Apple Mail all have different "default" names for folders inside the mailbox.

Code of Conduct

mdecimus commented 5 months ago

Stalwart already advertises special use folders. When an account is created it automatically creates Inbox, Sent Items, Trash and Junk Mail folders with their respective special use flags. It is also possible to create new special use folders by the client.

mightyBroccoli commented 5 months ago

The main point of this feature request is to map multiple common names to a single folder. The small excerpt all writes to /Trash when the folder Trash, Deleted Messages, Deleted Items, Rubbish or Gelöschte Objekte is used.

  mailbox "Trash" {
    auto = subscribe
    special_use = \Trash
  }
  mailbox "Deleted Messages" {
    special_use = \Trash
  }
  mailbox "Deleted Items" {
    special_use = \Trash
  }
  mailbox "Rubbish" {
    special_use = \Trash
  }
  mailbox "Gelöschte Objekte" {
    special_use = \Trash
  }

This allows multiple clients to "use" different folders that internally all map to the same folder, keeping the mailbox clean. I used AppleMail Outlook and Thunderbird and have now Trash ( from Thunderbird ) , Gelöschte Objekts ( from Outlook ) and Deleted Messages ( from Apple Mail ) all with their respective set of deleted messages.

For Trash it is not really a "big" issue, but this also applies to Junk , Archives and so on.

mdecimus commented 5 months ago

The problem I see is that JMAP requires each special use type (or role in JMAP terms) to be assigned to a single folder. So it won't be possible to have the \Trash special use flag in more than one mailbox. What could be done is to assign \Trash to just one folder and treat all others folders as aliases. This will not solve the problem you are having as your mail clients will keep creating their own folders but at least all messages will go to the same place.

mightyBroccoli commented 5 months ago

at least all messages will go to the same place

As this is the "main" issue I have with this behavior, I would think that this would still be beneficial to the server, and potentially it may be worth a consideration why jmap implements an imap feature and breaks it in the process. I think it's funny that the rfc states Servers providing IMAP access to the same data are encouraged to enforce these extra restrictions in IMAP as well.

mdecimus commented 5 months ago

In my opinion JMAP has fixed an IMAP issue. Roles should be unique per mailbox, I don't think it makes sense to have multiple folders with the \Trash or '\Sent` special-use role for instance.

IMAP clients should look for special-use folders by role rather than name and create these special-use folders if these don't exist already on the server.

mightyBroccoli commented 5 months ago

True, but they don't, and they very certainly won't in the foreseeable future or even at all. Sure it would be nice if every client does that but let's be honest, most clients won't. Thus people will end up with x different sent folders and that is annoying as f***.

JMAP will not work for people if it "break" all "not JMAP" clients by spamming folders. Requiring a change in such old standard will be difficult, I sense -> https://xkcd.com/927/

nomadturk commented 5 months ago

Well, also when you think about how many JMAP clients VS how many IMAP ones out there and how close are we to using JMAP in the near future....

mdecimus commented 5 months ago

This was implemented but should be used with caution as it is not only incompatible with JMAP but also RFC 8474 - IMAP Extension for Object Identifiers. For example, mapping Trash to Deleted Items will return the real MAILBOXID of Trash when the folder is created but once selected the MAILBOXID returned belongs to Deleted Items:

a create Trash
a OK [MAILBOXID (jeaaaabm)] Mailbox created.
a select "Trash"
* 0 EXISTS
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* 0 RECENT
* OK [PERMANENTFLAGS (\Deleted \Seen \Answered \Flagged \Draft \*)] All allowed
* OK [UIDVALIDITY 2197339414] UIDs valid
* OK [UIDNEXT 1] Next predicted UID
* OK [MAILBOXID (jeaaaaab)] Unique Mailbox ID
a OK [READ-WRITE] SELECT completed

This feature will also create issues deleting folder aliases to certain special folders such as Deleted Items and Junk Mail which Stalwart does not allow to be deleted.

In other words, personally I think this feature is a hack to support broken email clients. If a mail client does not allow to configure the name of special use folders and instead insists on creating their own, then this is a bug that should be fixed on the client side.

mightyBroccoli commented 5 months ago

I actually am not sure that this constitutes as implemented.

If the implementation breaks JMAP and potentially hinders other IMAP clients, then this fix should not be released.

I would call that a lose lose with the potential to implement one IMAP special case.