added smtp auth machinery

This commit is contained in:
cdramey committed 2021-01-24 13:59:53 -09:00
1 parent e1df5ac487
commit 081ecb0607
2 files changed
+14 -1

No files matched your search

+13
View File
@@ -21,6 +21,19 @@ func (a *AlarmEmail) Alarm(grp string, hst string, chk string, alerr error) erro
return err
}
if a.User != "" && a.Pass != "" {
hostname := a.SMTP
hn := strings.Split(a.SMTP, ":")
if len(hn) > 1 {
hostname = hn[0]
}
auth := smtp.PlainAuth("", a.User, a.Pass, hostname)
err = c.Auth(auth)
if err != nil {
return err
}
}
helo := "localhost"
tspl := strings.Split(a.From, "@")
if len(tspl) > 1 {