Skip to content

Commit

Permalink
Allow sending mail without credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Castell committed Jan 14, 2019
1 parent 1ef9356 commit 72d9573
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions dkron/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,12 @@ func (n *Notifier) sendExecutionEmail() {
}

serverAddr := fmt.Sprintf("%s:%d", n.Config.MailHost, n.Config.MailPort)
err := e.Send(serverAddr, smtp.PlainAuth("", n.Config.MailUsername, n.Config.MailPassword, n.Config.MailHost))
if err != nil {

var auth smtp.Auth
if n.Config.MailUsername != "" && n.Config.MailPassword != "" {
auth = smtp.PlainAuth("", n.Config.MailUsername, n.Config.MailPassword, n.Config.MailHost)
}
if err := em.Send(serverAddr, auth); err != nil {
log.WithError(err).Error("notifier: Error sending email")
}
}
Expand Down

0 comments on commit 72d9573

Please sign in to comment.