Skip to content

Instantly share code, notes, and snippets.

@felixbuenemann
Created November 21, 2014 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felixbuenemann/d80fa2ebe7396e2c7dd7 to your computer and use it in GitHub Desktop.
Save felixbuenemann/d80fa2ebe7396e2c7dd7 to your computer and use it in GitHub Desktop.
diff --git a/actions.go b/actions.go
index 93cb126..69a4235 100644
--- a/actions.go
+++ b/actions.go
@@ -179,11 +179,18 @@ func sendEmail(e *EmailNotifier, doc bytes.Buffer) error {
} else {
util.Debug("Sending email to %s", e.To)
util.Debug("Sending email:\n%s", string(doc.Bytes()))
- auth := smtp.PlainAuth("", e.Username, e.Password, e.Host)
- err := smtp.SendMail(e.Host+":587", auth, e.From,
- []string{e.To}, doc.Bytes())
- if err != nil {
- return err
+ if e.Username != "" {
+ auth := smtp.PlainAuth("", e.Username, e.Password, e.Host)
+ err := smtp.SendMail(e.Host+":587", auth, e.From,
+ []string{e.To}, doc.Bytes())
+ if err != nil {
+ return err
+ }
+ } else {
+ err := smtp.SendMail(e.Host+":25", nil, e.From, []string{e.To}, doc.Bytes())
+ if err != nil {
+ return err
+ }
}
}
return nil
@@ -192,11 +199,11 @@ func sendEmail(e *EmailNotifier, doc bytes.Buffer) error {
func (e *EmailNotifier) setup(hash map[string]string) error {
usr, ok := hash["username"]
if !ok {
- return errors.New("You must have a username configured to send email")
+ usr = ""
}
pwd, ok := hash["password"]
if !ok {
- return errors.New("You must have a password configured to send email")
+ pwd = ""
}
host, ok := hash["smtp_server"]
if !ok {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment