diff options
author | Peter <peter@smitmail.eu> | 2014-12-18 13:58:18 +0200 |
---|---|---|
committer | Peter <peter@smitmail.eu> | 2014-12-18 13:58:48 +0200 |
commit | 5ffeca35e78544f239b73c46bf82605ec9baa3fe (patch) | |
tree | 3f51baf01e4ed16c1c0bf0c88a6867e44e98de04 /modules | |
parent | 87be137b881ab868df30aa7e35923d6f14606c79 (diff) | |
download | gitea-5ffeca35e78544f239b73c46bf82605ec9baa3fe.tar.gz gitea-5ffeca35e78544f239b73c46bf82605ec9baa3fe.zip |
Add option to use CRAM-MD5 as authentication method in the mailer
Diffstat (limited to 'modules')
-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..daee5d76e8 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, "PLAIN") { + auth = smtp.PlainAuth("", settings.User, settings.Passwd, host) + } else if strings.Contains(options, "CRAM-MD5") { + auth = smtp.CRAMMD5Auth(settings.User, settings.Passwd) + } + + if auth != nil { + if err = client.Auth(auth); err != nil { + return err + } } } |