From d18fc8fc35fd1edb6910483df90d37012bd970e2 Mon Sep 17 00:00:00 2001 From: Andrew Karpow Date: Sun, 16 Feb 2014 22:36:01 +0100 Subject: [PATCH] make smtp-auth optional --- pkg/mail/mail.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/mail/mail.go b/pkg/mail/mail.go index aa63d444f..2bc83938b 100644 --- a/pkg/mail/mail.go +++ b/pkg/mail/mail.go @@ -122,7 +122,11 @@ func Send(msg *Message) error { // format the raw email message body body := fmt.Sprintf(emailTemplate, msg.Sender, msg.To, msg.Subject, msg.Body) - auth := smtp.PlainAuth("", s.SmtpUsername, s.SmtpPassword, s.SmtpServer) + + var auth smtp.Auth + if len(s.SmtpUsername) > 0 { + auth = smtp.PlainAuth("", s.SmtpUsername, s.SmtpPassword, s.SmtpServer) + } addr := fmt.Sprintf("%s:%s", s.SmtpServer, s.SmtpPort) err = smtp.SendMail(addr, auth, msg.Sender, []string{msg.To}, []byte(body))