From: Alukardd Date: Sun, 7 Dec 2014 13:07:48 +0000 (+0300) Subject: Allow send mail without authentication if SMTP server allow this X-Git-Tag: v0.9.99~1595^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=21081836ba2c408aad04591980f5551a58fdb89d;p=gitea.git Allow send mail without authentication if SMTP server allow this --- diff --git a/modules/mailer/mailer.go b/modules/mailer/mailer.go index df3efb610b..474e1481cd 100644 --- a/modules/mailer/mailer.go +++ b/modules/mailer/mailer.go @@ -127,7 +127,10 @@ func Send(msg *Message) (int, error) { return 0, fmt.Errorf("empty email body") } - auth := smtp.PlainAuth("", setting.MailService.User, setting.MailService.Passwd, host[0]) + var auth smtp.Auth + if len(setting.MailService.Passwd) > 0 { + auth = smtp.PlainAuth("", setting.MailService.User, setting.MailService.Passwd, host[0]) + } if msg.Massive { // send mail to multiple emails one by one