From 8bc1e956cf554aa47e8c8fbda9b977d1046db9cd Mon Sep 17 00:00:00 2001 From: CalciumIon <1808837298@qq.com> Date: Wed, 4 Sep 2024 19:44:29 +0800 Subject: [PATCH] fix: email --- common/email.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/email.go b/common/email.go index 905f385..72e8979 100644 --- a/common/email.go +++ b/common/email.go @@ -10,7 +10,7 @@ import ( ) func generateMessageID() string { - domain := strings.Split(SMTPFrom, "@")[1] + domain := strings.Split(SMTPAccount, "@")[1] return fmt.Sprintf("<%d.%s@%s>", time.Now().UnixNano(), GetRandomString(12), domain) } @@ -18,6 +18,9 @@ func SendEmail(subject string, receiver string, content string) error { if SMTPFrom == "" { // for compatibility SMTPFrom = SMTPAccount } + if SMTPServer == "" && SMTPAccount == "" { + return fmt.Errorf("SMTP 服务器未配置") + } encodedSubject := fmt.Sprintf("=?UTF-8?B?%s?=", base64.StdEncoding.EncodeToString([]byte(subject))) mail := []byte(fmt.Sprintf("To: %s\r\n"+ "From: %s<%s>\r\n"+