remove last remnants of treating a mailbox named "Sent" specially, in favor of special-use mailbox flags

a few places still looked at the name "Sent". but since we have special-use
flags, we should always look at those. this also changes the config so admins
can specify different names for the special-use mailboxes to create for new
accounts, e.g. in a different language. the old config option is still
understood, just deprecated.
This commit is contained in:
Mechiel Lukkien
2023-08-09 09:31:23 +02:00
parent 19b819d222
commit 34ede1075d
12 changed files with 176 additions and 52 deletions

View File

@ -644,9 +644,33 @@ func PrepareStaticConfig(ctx context.Context, configFile string, conf *Config, c
c.SpecifiedSMTPListenIPs = nil
}
var zerouse config.SpecialUseMailboxes
if len(c.DefaultMailboxes) > 0 && (c.InitialMailboxes.SpecialUse != zerouse || len(c.InitialMailboxes.Regular) > 0) {
addErrorf("cannot have both DefaultMailboxes and InitialMailboxes")
}
// DefaultMailboxes is deprecated.
for _, mb := range c.DefaultMailboxes {
checkMailboxNormf(mb, "default mailbox")
}
checkSpecialUseMailbox := func(nameOpt string) {
if nameOpt != "" {
checkMailboxNormf(nameOpt, "special-use initial mailbox")
if strings.EqualFold(nameOpt, "inbox") {
addErrorf("initial mailbox cannot be set to Inbox (Inbox is always created)")
}
}
}
checkSpecialUseMailbox(c.InitialMailboxes.SpecialUse.Archive)
checkSpecialUseMailbox(c.InitialMailboxes.SpecialUse.Draft)
checkSpecialUseMailbox(c.InitialMailboxes.SpecialUse.Junk)
checkSpecialUseMailbox(c.InitialMailboxes.SpecialUse.Sent)
checkSpecialUseMailbox(c.InitialMailboxes.SpecialUse.Trash)
for _, name := range c.InitialMailboxes.Regular {
checkMailboxNormf(name, "regular initial mailbox")
if strings.EqualFold(name, "inbox") {
addErrorf("initial regular mailbox cannot be set to Inbox (Inbox is always created)")
}
}
checkTransportSMTP := func(name string, isTLS bool, t *config.TransportSMTP) {
var err error