Check error on SplitHostPort.

This commit is contained in:
Logan Hanks 2015-03-12 20:57:29 -07:00
parent e746596de0
commit 183ee95a3e

View File

@ -211,8 +211,13 @@ func (n *notifier) sendEmailNotification(to string, a *Alert) error {
}
identity := os.Getenv("SMTP_AUTH_IDENTITY")
// We need to know the hostname for auth (not to mention TLS).
host, _, err := net.SplitHostPort(*smtpSmartHost)
if err != nil {
return fmt.Errorf("invalid address: %s", err)
}
// PLAIN auth requires TLS to be started first.
host, _, _ := net.SplitHostPort(*smtpSmartHost)
if err := c.StartTLS(&tls.Config{ServerName: host}); err != nil {
return fmt.Errorf("starttls failed: %s", err)
}