1
0
Fork 0
forked from forgejo/forgejo

setting: Allow aliases for some email settings

The keys for setting the username and password for incoming and outgoing
mail are inconsisent: one uses `USERNAME` and `PASSWORD`, the other uses
`USER` and `PASSWD`.

To make things simpler, allow both to be configured by either, thus,
`[mailer].USERNAME` and `[mailer.PASSWORD]` will be aliases for `.USER`
and `.PASSWD`, and similarly, `[email.incoming].USER` and
`[email.incoming].PASSWD` will be aliases for `.USERNAME` and
`.PASSWORD`.

Fixes #3355.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
This commit is contained in:
Gergely Nagy 2024-04-22 15:58:19 +02:00
parent 56831d345d
commit 073cc891c6
No known key found for this signature in database
4 changed files with 54 additions and 0 deletions

View file

@ -38,6 +38,15 @@ func loadIncomingEmailFrom(rootCfg ConfigProvider) {
return
}
// Handle aliases
sec := rootCfg.Section("email.incoming")
if sec.HasKey("USER") && !sec.HasKey("USERNAME") {
IncomingEmail.Username = sec.Key("USER").String()
}
if sec.HasKey("PASSWD") && !sec.HasKey("PASSWORD") {
IncomingEmail.Password = sec.Key("PASSWD").String()
}
if err := checkReplyToAddress(IncomingEmail.ReplyToAddress); err != nil {
log.Fatal("Invalid incoming_mail.REPLY_TO_ADDRESS (%s): %v", IncomingEmail.ReplyToAddress, err)
}