setting: Infer [email.incoming].PORT from .USE_TLS

If `[email.incoming].USE_TLS` is set, but the port isn't, infer the
default from `.USE_TLS`: set the port to 993 if using tls, and to 143
otherwise. Explicitly setting a port overrides this.

Fixes #3357.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
This commit is contained in:
Gergely Nagy 2024-04-22 16:27:32 +02:00
parent 073cc891c6
commit 0cb46f63df
No known key found for this signature in database
2 changed files with 68 additions and 9 deletions

View file

@ -47,6 +47,15 @@ func loadIncomingEmailFrom(rootCfg ConfigProvider) {
IncomingEmail.Password = sec.Key("PASSWD").String()
}
// Infer Port if not set
if IncomingEmail.Port == 0 {
if IncomingEmail.UseTLS {
IncomingEmail.Port = 993
} else {
IncomingEmail.Port = 143
}
}
if err := checkReplyToAddress(IncomingEmail.ReplyToAddress); err != nil {
log.Fatal("Invalid incoming_mail.REPLY_TO_ADDRESS (%s): %v", IncomingEmail.ReplyToAddress, err)
}