diff options
author | 无闻 <u@gogs.io> | 2014-12-18 16:49:11 -0500 |
---|---|---|
committer | 无闻 <u@gogs.io> | 2014-12-18 16:49:11 -0500 |
commit | d01e7b01733b215f8adcff07518e2f89fbc6448d (patch) | |
tree | d4ec980238d1b785a240a9cd473ef432f7a1ae68 | |
parent | bb267e30b655bbbbbc5536028171f76a655d030a (diff) | |
parent | eca42bcb4480d23c3bd0c3bda05f1f7e185053cd (diff) | |
download | gitea-d01e7b01733b215f8adcff07518e2f89fbc6448d.tar.gz gitea-d01e7b01733b215f8adcff07518e2f89fbc6448d.zip |
Merge pull request #762 from phsmit/crammd5
Crammd5
-rw-r--r-- | modules/mailer/mailer.go | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/modules/mailer/mailer.go b/modules/mailer/mailer.go index 6d75fa3f2c..2347235909 100644 --- a/modules/mailer/mailer.go +++ b/modules/mailer/mailer.go @@ -108,14 +108,21 @@ func sendMail(settings *setting.Mailer, from string, recipients []string, msgCon } } - auth_available, _ := client.Extension("AUTH") + auth_available, options := client.Extension("AUTH") - // Possible improvement: only plain authentication is now available. - // Maybe in future CRAM MD5 as well? if auth_available && len(settings.User) > 0 { - auth := smtp.PlainAuth("", settings.User, settings.Passwd, host) - if err = client.Auth(auth); err != nil { - return err + var auth smtp.Auth + + if strings.Contains(options, "CRAM-MD5") { + auth = smtp.CRAMMD5Auth(settings.User, settings.Passwd) + } else if strings.Contains(options, "PLAIN") { + auth = smtp.PlainAuth("", settings.User, settings.Passwd, host) + } + + if auth != nil { + if err = client.Auth(auth); err != nil { + return err + } } } |