diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/mailer/mailer.go | 5 | ||||
-rw-r--r-- | modules/setting/setting.go | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/modules/mailer/mailer.go b/modules/mailer/mailer.go index a54e836173..e9b752e14d 100644 --- a/modules/mailer/mailer.go +++ b/modules/mailer/mailer.go @@ -122,11 +122,10 @@ func (s *smtpSender) Send(from string, to []string, msg io.WriterTo) error { } defer conn.Close() - isSecureConn := false + isSecureConn := opts.IsTLSEnabled || (strings.HasSuffix(port, "465")) // Start TLS directly if the port ends with 465 (SMTPS protocol) - if strings.HasSuffix(port, "465") { + if isSecureConn { conn = tls.Client(conn, tlsconfig) - isSecureConn = true } client, err := smtp.NewClient(conn, host) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index b0bcd2ead8..1c4814189a 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -1523,6 +1523,7 @@ type Mailer struct { SkipVerify bool UseCertificate bool CertFile, KeyFile string + IsTLSEnabled bool // Sendmail sender UseSendmail bool @@ -1556,6 +1557,7 @@ func newMailService() { UseCertificate: sec.Key("USE_CERTIFICATE").MustBool(), CertFile: sec.Key("CERT_FILE").String(), KeyFile: sec.Key("KEY_FILE").String(), + IsTLSEnabled: sec.Key("IS_TLS_ENABLED").MustBool(), UseSendmail: sec.Key("USE_SENDMAIL").MustBool(), SendmailPath: sec.Key("SENDMAIL_PATH").MustString("sendmail"), |