diff --git a/config.go b/config.go index 3df5a0e..69cc30c 100644 --- a/config.go +++ b/config.go @@ -72,6 +72,7 @@ func (app *appContext) loadConfig() error { app.MustSetValue("deletion", "email_text", "jfa-go:"+"deleted.txt") app.MustSetValue("smtp", "hello_hostname", "localhost") + app.MustSetValue("smtp", "cert_validation", "true") jfUrl := app.config.Section("jellyfin").Key("server").String() if !(strings.HasPrefix(jfUrl, "http://") || strings.HasPrefix(jfUrl, "https://")) { diff --git a/email.go b/email.go index 7bb949f..b5c5563 100644 --- a/email.go +++ b/email.go @@ -84,7 +84,7 @@ func NewEmailer(app *appContext) *Emailer { if username == "" && password != "" { username = emailer.fromAddr } - err := emailer.NewSMTP(app.config.Section("smtp").Key("server").String(), app.config.Section("smtp").Key("port").MustInt(465), username, password, sslTLS, app.config.Section("smtp").Key("ssl_cert").MustString(""), app.config.Section("smtp").Key("hello_hostname").String(), app.config.Section("smtp").Key("cert-validation").MustBool(true)) + err := emailer.NewSMTP(app.config.Section("smtp").Key("server").String(), app.config.Section("smtp").Key("port").MustInt(465), username, password, sslTLS, app.config.Section("smtp").Key("ssl_cert").MustString(""), app.config.Section("smtp").Key("hello_hostname").String(), app.config.Section("smtp").Key("cert_validation").MustBool(true)) if err != nil { app.err.Printf("Error while initiating SMTP mailer: %v", err) } @@ -131,7 +131,7 @@ func (emailer *Emailer) NewSMTP(server string, port int, username, password stri // x509.SystemCertPool is unavailable on windows if PLATFORM == "windows" { sender.Client.TLSConfig = &tls.Config{ - InsecureSkipVerify: validateCertificate, + InsecureSkipVerify: !validateCertificate, ServerName: server, } emailer.sender = sender @@ -149,7 +149,7 @@ func (emailer *Emailer) NewSMTP(server string, port int, username, password stri } } sender.Client.TLSConfig = &tls.Config{ - InsecureSkipVerify: validateCertificate, + InsecureSkipVerify: !validateCertificate, ServerName: server, RootCAs: rootCAs, } diff --git a/ts/setup.ts b/ts/setup.ts index 2b241c7..02fb37d 100644 --- a/ts/setup.ts +++ b/ts/setup.ts @@ -296,8 +296,7 @@ const settings = { "encryption": new Select(get("smtp-encryption")), "server": new Input(get("smtp-server")), "port": new Input(get("smtp-port")), - "password": new Input(get("smtp-password")), - "cert-validation": new Input(get("smtp-cert-validation")) + "password": new Input(get("smtp-password")) }, "ombi": { "enabled": new Checkbox(get("ombi-enabled"), "", false, "ombi", "enabled"),