Skip to content
Permalink
Browse files

SMTP email notifier OnTest() fix

  • Loading branch information...
hunterlong committed Sep 20, 2019
1 parent 9d9f91f commit 15e3b83f9b62566d82aeadd92a156c2e8fefbc90
Showing with 2 additions and 22 deletions.
  1. +2 −22 notifiers/email.go
@@ -24,7 +24,6 @@ import (
"github.com/hunterlong/statping/types"
"github.com/hunterlong/statping/utils"
"html/template"
"net/smtp"
"time"
)

@@ -225,24 +224,6 @@ func (u *email) OnSave() error {

// OnTest triggers when this notifier has been saved
func (u *email) OnTest() error {
host := fmt.Sprintf("%v:%v", u.Host, u.Port)
dial, err := smtp.Dial(host)
if err != nil {
return err
}
if u.ApiKey != "true" {
err = dial.StartTLS(&tls.Config{InsecureSkipVerify: true})
if err != nil {
return err
}
}
if u.Username != "" || u.Password != "" {
auth := smtp.PlainAuth("", u.Username, u.Password, host)
err = dial.Auth(auth)
if err != nil {
return err
}
}
testService := &types.Service{
Id: 1,
Name: "Example Service",
@@ -261,11 +242,10 @@ func (u *email) OnTest() error {
To: u.Var2,
Subject: fmt.Sprintf("Service %v is Back Online", testService.Name),
Template: mainEmailTemplate,
Data: interface{}(testService),
Data: testService,
From: u.Var1,
}
err = u.dialSend(email)
return err
return u.dialSend(email)
}

func (u *email) dialSend(email *emailOutgoing) error {

0 comments on commit 15e3b83

Please sign in to comment.
You can’t perform that action at this time.