notifications: pick SMTP auth method automatically by default

This introduces the new value `auto` for NOTIFICATIONS_SMTP_AUTHENTICATION.
Which will make the notifications service automatically pick an authentication
mechanism that the server supports. This is also the new default behavior.

This also removes most of the other default settings for the SMTP
configuration. The default values were of no real use for this service.

Closes: #7356
This commit is contained in:
Ralf Haferkamp
2023-09-26 17:16:32 +02:00
committed by Ralf Haferkamp
parent 246ec1ecc9
commit f6b792a517
5 changed files with 13 additions and 7 deletions

View File

@@ -138,6 +138,7 @@ config = {
"NOTIFICATIONS_SMTP_HOST": "email",
"NOTIFICATIONS_SMTP_PORT": "2500",
"NOTIFICATIONS_SMTP_INSECURE": "true",
"NOTIFICATIONS_SMTP_SENDER": "ownCloud <noreply@example.com>",
},
},
"apiAntivirus": {

View File

@@ -0,0 +1,7 @@
Enhancement: New value `auto` for NOTIFICATIONS_SMTP_AUTHENTICATION
This cause the notifications service to automatically pick a suitable authentication
method to use with the configured SMTP server. This is also the new default behavior.
The previous default was to not use authentication at all.
https://github.com/owncloud/ocis/issues/7356

View File

@@ -69,6 +69,8 @@ func (m Mail) getMailClient() (*mail.SMTPClient, error) {
server.Authentication = mail.AuthCRAMMD5
case "none":
server.Authentication = mail.AuthNone
case "auto", "":
server.Authentication = mail.AuthAuto
default:
return nil, errors.New("unknown mail authentication method")
}

View File

@@ -39,11 +39,11 @@ type Notifications struct {
type SMTP struct {
Host string `yaml:"smtp_host" env:"NOTIFICATIONS_SMTP_HOST" desc:"SMTP host to connect to."`
Port int `yaml:"smtp_port" env:"NOTIFICATIONS_SMTP_PORT" desc:"Port of the SMTP host to connect to."`
Sender string `yaml:"smtp_sender" env:"NOTIFICATIONS_SMTP_SENDER" desc:"Sender address of emails that will be sent."`
Sender string `yaml:"smtp_sender" env:"NOTIFICATIONS_SMTP_SENDER" desc:"Sender address of emails that will be sent (e.g. 'ownCloud <noreply@example.com>'."`
Username string `yaml:"smtp_username" env:"NOTIFICATIONS_SMTP_USERNAME" desc:"Username for the SMTP host to connect to."`
Password string `yaml:"smtp_password" env:"NOTIFICATIONS_SMTP_PASSWORD" desc:"Password for the SMTP host to connect to."`
Insecure bool `yaml:"insecure" env:"NOTIFICATIONS_SMTP_INSECURE" desc:"Allow insecure connections to the SMTP server."`
Authentication string `yaml:"smtp_authentication" env:"NOTIFICATIONS_SMTP_AUTHENTICATION" desc:"Authentication method for the SMTP communication. Possible values are 'login', 'plain', 'crammd5', 'none'"`
Authentication string `yaml:"smtp_authentication" env:"NOTIFICATIONS_SMTP_AUTHENTICATION" desc:"Authentication method for the SMTP communication. Possible values are 'login', 'plain', 'crammd5', 'none' or 'auto'. If set to 'auto' or unset, the authentication method is automatically negotiated with the server."`
Encryption string `yaml:"smtp_encryption" env:"NOTIFICATIONS_SMTP_ENCRYPTION" desc:"Encryption method for the SMTP communication. Possible values are 'starttls', 'ssl', 'ssltls', 'tls' and 'none'." deprecationVersion:"5.0.0" removalVersion:"6.0.0" deprecationInfo:"The NOTIFICATIONS_SMTP_ENCRYPTION values 'ssl' and 'tls' are deprecated and will be removed in the future." deprecationReplacement:"Use 'starttls' instead of 'tls' and 'ssltls' instead of 'ssl'."`
}

View File

@@ -31,11 +31,7 @@ func DefaultConfig() *config.Config {
WebUIURL: "https://localhost:9200",
Notifications: config.Notifications{
SMTP: config.SMTP{
Host: "",
Port: 1025,
Sender: "ownCloud <noreply@example.com>",
Authentication: "none",
Encryption: "none",
Encryption: "none",
},
Events: config.Events{
Endpoint: "127.0.0.1:9233",