Skip to content

Commit

Permalink
Merge pull request #88 from notandy/master
Browse files Browse the repository at this point in the history
Make smtp authentication optional
  • Loading branch information
bradrydzewski committed Feb 16, 2014
2 parents 4648ca9 + d18fc8f commit d14b465
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/mail/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit d14b465

Please sign in to comment.