diff options
author | Lanre Adelowo <adelowomailbox@gmail.com> | 2018-11-26 20:21:42 +0100 |
---|---|---|
committer | techknowlogick <hello@techknowlogick.com> | 2018-11-26 14:21:41 -0500 |
commit | 3a1ed825299d4686e4c5efc5324e0a70fc7dee2b (patch) | |
tree | 248148daee9706e1fb98fb5a9e2adcdf227cd01a /modules/mailer | |
parent | ce9a5173feafd0903257229f8e2ffcc01b9ebcd2 (diff) | |
download | gitea-3a1ed825299d4686e4c5efc5324e0a70fc7dee2b.tar.gz gitea-3a1ed825299d4686e4c5efc5324e0a70fc7dee2b.zip |
Explicitly decide whether to use TLS in mailer's configuration (#5024)
* explicitly decide on using TLS for mail connections
* explicitly decide on using TLS for mail connections
* keep compatibility
Diffstat (limited to 'modules/mailer')
-rw-r--r-- | modules/mailer/mailer.go | 5 |
1 files changed, 2 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) |