mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-24 02:03:57 +01:00
Add option to use CRAM-MD5 as authentication method in the mailer
This commit is contained in:
parent
87be137b88
commit
5ffeca35e7
1 changed files with 13 additions and 6 deletions
|
@ -108,16 +108,23 @@ 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 {
|
if auth_available && len(settings.User) > 0 {
|
||||||
auth := smtp.PlainAuth("", settings.User, settings.Passwd, host)
|
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 {
|
if err = client.Auth(auth); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err = client.Mail(from); err != nil {
|
if err = client.Mail(from); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue