mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 04:10:20 +08:00
feat: test SMTP connection with browser parameters (#2986)
This commit is contained in:
@ -27,11 +27,12 @@ import (
|
||||
)
|
||||
|
||||
type EmailForm struct {
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
Sender string `json:"sender"`
|
||||
Receivers []string `json:"receivers"`
|
||||
Provider string `json:"provider"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
Sender string `json:"sender"`
|
||||
Receivers []string `json:"receivers"`
|
||||
Provider string `json:"provider"`
|
||||
ProviderObject object.Provider `json:"providerObject"`
|
||||
}
|
||||
|
||||
type SmsForm struct {
|
||||
@ -74,7 +75,6 @@ func (c *ApiController) SendEmail() {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
} else {
|
||||
// called by Casdoor SDK via Client ID & Client Secret, so the used Email provider will be the application' Email provider or the default Email provider
|
||||
provider, err = c.GetProviderFromContext("Email")
|
||||
@ -84,6 +84,13 @@ func (c *ApiController) SendEmail() {
|
||||
}
|
||||
}
|
||||
|
||||
if emailForm.ProviderObject.Name != "" {
|
||||
if emailForm.ProviderObject.ClientSecret == "***" {
|
||||
emailForm.ProviderObject.ClientSecret = provider.ClientSecret
|
||||
}
|
||||
provider = &emailForm.ProviderObject
|
||||
}
|
||||
|
||||
// when receiver is the reserved keyword: "TestSmtpServer", it means to test the SMTP server instead of sending a real Email
|
||||
if len(emailForm.Receivers) == 1 && emailForm.Receivers[0] == "TestSmtpServer" {
|
||||
err = object.DailSmtpServer(provider)
|
||||
|
Reference in New Issue
Block a user