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"+