mirror of
https://github.com/harness/drone.git
synced 2025-05-12 06:59:54 +08:00
Merge pull request #88 from notandy/master
Make smtp authentication optional
This commit is contained in:
commit
d14b465ab6
@ -122,7 +122,11 @@ func Send(msg *Message) error {
|
|||||||
|
|
||||||
// format the raw email message body
|
// format the raw email message body
|
||||||
body := fmt.Sprintf(emailTemplate, msg.Sender, msg.To, msg.Subject, msg.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)
|
addr := fmt.Sprintf("%s:%s", s.SmtpServer, s.SmtpPort)
|
||||||
|
|
||||||
err = smtp.SendMail(addr, auth, msg.Sender, []string{msg.To}, []byte(body))
|
err = smtp.SendMail(addr, auth, msg.Sender, []string{msg.To}, []byte(body))
|
||||||
|
Loading…
Reference in New Issue
Block a user