fix: Fix the issue of garbled Chinese characters in recipient names and email titles in email alerts (#11516)

#11264
This commit is contained in:
2025-12-29 17:37:35 +08:00 committed by GitHub
parent 50947f4ddc
commit e3dea80cb7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,6 +4,7 @@ import (
"context"
"crypto/tls"
"fmt"
"mime"
"net"
"net/http"
"net/smtp"
@ -119,9 +120,11 @@ func parseRecipients(recipient string) []string {
func buildMessage(config SMTPConfig, message EmailMessage, toList []string) (string, error) {
headers := make(map[string]string)
headers["From"] = config.From
encodedFrom := mime.BEncoding.Encode("UTF-8", config.From)
headers["From"] = encodedFrom
encodedSubject := mime.BEncoding.Encode("UTF-8", message.Subject)
headers["Subject"] = encodedSubject
headers["To"] = strings.Join(toList, ",")
headers["Subject"] = message.Subject
headers["Date"] = time.Now().UTC().Format(time.RFC1123Z)
if message.IsHTML {