Allow optional SMTP TLS verification bypass
This commit is contained in:
5
email.go
5
email.go
@@ -58,9 +58,10 @@ func sendAlertEmail(settings EmailSettings, alerts []Alert, test bool) error {
|
||||
}
|
||||
message := []byte("From: " + settings.From + "\r\nTo: " + settings.To + "\r\nSubject: " + subject + "\r\nMIME-Version: 1.0\r\nContent-Type: text/plain; charset=UTF-8\r\nContent-Transfer-Encoding: 8bit\r\n\r\n" + body + "\r\n")
|
||||
address := net.JoinHostPort(settings.Host, fmt.Sprint(settings.Port))
|
||||
tlsConfig := &tls.Config{ServerName: settings.Host, MinVersion: tls.VersionTLS12, InsecureSkipVerify: settings.SkipTLSVerify} //nolint:gosec -- explicit private-network option
|
||||
var client *smtp.Client
|
||||
if settings.Port == 465 {
|
||||
connection, err := tls.Dial("tcp", address, &tls.Config{ServerName: settings.Host, MinVersion: tls.VersionTLS12})
|
||||
connection, err := tls.Dial("tcp", address, tlsConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -75,7 +76,7 @@ func sendAlertEmail(settings EmailSettings, alerts []Alert, test bool) error {
|
||||
return err
|
||||
}
|
||||
if ok, _ := client.Extension("STARTTLS"); ok {
|
||||
if err = client.StartTLS(&tls.Config{ServerName: settings.Host, MinVersion: tls.VersionTLS12}); err != nil {
|
||||
if err = client.StartTLS(tlsConfig); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user