|
|
@@ -9,6 +9,11 @@ import (
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
+func generateMessageID() string {
|
|
|
+ domain := strings.Split(SMTPFrom, "@")[1]
|
|
|
+ return fmt.Sprintf("<%d.%s@%s>", time.Now().UnixNano(), GetRandomString(12), domain)
|
|
|
+}
|
|
|
+
|
|
|
func SendEmail(subject string, receiver string, content string) error {
|
|
|
if SMTPFrom == "" { // for compatibility
|
|
|
SMTPFrom = SMTPAccount
|
|
|
@@ -18,8 +23,9 @@ func SendEmail(subject string, receiver string, content string) error {
|
|
|
"From: %s<%s>\r\n"+
|
|
|
"Subject: %s\r\n"+
|
|
|
"Date: %s\r\n"+
|
|
|
+ "Message-ID: %s\r\n"+ // 添加 Message-ID 头
|
|
|
"Content-Type: text/html; charset=UTF-8\r\n\r\n%s\r\n",
|
|
|
- receiver, SystemName, SMTPFrom, encodedSubject, time.Now().Format(time.RFC1123Z), content))
|
|
|
+ receiver, SystemName, SMTPFrom, encodedSubject, time.Now().Format(time.RFC1123Z), generateMessageID(), content))
|
|
|
auth := smtp.PlainAuth("", SMTPAccount, SMTPToken, SMTPServer)
|
|
|
addr := fmt.Sprintf("%s:%d", SMTPServer, SMTPPort)
|
|
|
to := strings.Split(receiver, ";")
|