From 72d957395822ccca7e8d8c7637f41ef400cee92d Mon Sep 17 00:00:00 2001 From: Victor Castell Date: Mon, 14 Jan 2019 22:41:47 +0100 Subject: [PATCH] Allow sending mail without credentials --- dkron/notifier.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dkron/notifier.go b/dkron/notifier.go index 046b1df10..9a50c8831 100644 --- a/dkron/notifier.go +++ b/dkron/notifier.go @@ -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") } }