diff --git a/common/constants.go b/common/constants.go index ed50fae6..dd4f3b04 100644 --- a/common/constants.go +++ b/common/constants.go @@ -62,6 +62,10 @@ var EmailDomainWhitelist = []string{ "yahoo.com", "foxmail.com", } +var EmailLoginAuthServerList = []string{ + "smtp.sendcloud.net", + "smtp.azurecomm.net", +} var DebugEnabled bool var MemoryCacheEnabled bool diff --git a/common/email.go b/common/email.go index 8eb575f3..18e6dbf7 100644 --- a/common/email.go +++ b/common/email.go @@ -5,6 +5,7 @@ import ( "encoding/base64" "fmt" "net/smtp" + "slices" "strings" "time" ) @@ -79,7 +80,7 @@ func SendEmail(subject string, receiver string, content string) error { if err != nil { return err } - } else if isOutlookServer(SMTPAccount) || SMTPServer == "smtp.azurecomm.net" { + } else if isOutlookServer(SMTPAccount) || slices.Contains(EmailLoginAuthServerList, SMTPServer) { auth = LoginAuth(SMTPAccount, SMTPToken) err = smtp.SendMail(addr, auth, SMTPFrom, to, mail) } else { diff --git a/common/utils.go b/common/utils.go index e57801e3..587de537 100644 --- a/common/utils.go +++ b/common/utils.go @@ -7,7 +7,6 @@ import ( "encoding/base64" "encoding/json" "fmt" - "github.com/pkg/errors" "html/template" "io" "log" @@ -22,6 +21,7 @@ import ( "time" "github.com/google/uuid" + "github.com/pkg/errors" ) func OpenBrowser(url string) {