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
This commit is contained in:
Lanre Adelowo authored and techknowlogick committed 2018-11-26 14:21:41 -05:00
1 parent ce9a5173fe
commit 3a1ed82529
4 files changed
+10 -6

No files matched your search

+2 -3
View File
@@ -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)