feat: 增加sendcloud邮件服务器的支持 (#947)
* 增加sendcloud邮件服务器的支持 * 调整代码结构 * Used slince.Contains function --------- Co-authored-by: shih <shih@knownsec.com>
This commit is contained in:
@@ -62,6 +62,10 @@ var EmailDomainWhitelist = []string{
|
|||||||
"yahoo.com",
|
"yahoo.com",
|
||||||
"foxmail.com",
|
"foxmail.com",
|
||||||
}
|
}
|
||||||
|
var EmailLoginAuthServerList = []string{
|
||||||
|
"smtp.sendcloud.net",
|
||||||
|
"smtp.azurecomm.net",
|
||||||
|
}
|
||||||
|
|
||||||
var DebugEnabled bool
|
var DebugEnabled bool
|
||||||
var MemoryCacheEnabled bool
|
var MemoryCacheEnabled bool
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/smtp"
|
"net/smtp"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -79,7 +80,7 @@ func SendEmail(subject string, receiver string, content string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else if isOutlookServer(SMTPAccount) || SMTPServer == "smtp.azurecomm.net" {
|
} else if isOutlookServer(SMTPAccount) || slices.Contains(EmailLoginAuthServerList, SMTPServer) {
|
||||||
auth = LoginAuth(SMTPAccount, SMTPToken)
|
auth = LoginAuth(SMTPAccount, SMTPToken)
|
||||||
err = smtp.SendMail(addr, auth, SMTPFrom, to, mail)
|
err = smtp.SendMail(addr, auth, SMTPFrom, to, mail)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
@@ -22,6 +21,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
func OpenBrowser(url string) {
|
func OpenBrowser(url string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user