by Robin at 20240823

This commit is contained in:
Leufolium 2024-08-23 17:04:31 +08:00
parent 95e83bafe2
commit 54bbcf331e
1 changed files with 4 additions and 2 deletions

View File

@ -14,6 +14,7 @@ import (
func SendRavenIQTestResult(mail *dbstruct.Email, address, password string) error { func SendRavenIQTestResult(mail *dbstruct.Email, address, password string) error {
url := mail.MediaComponent.Images[0].Urls[0] url := mail.MediaComponent.Images[0].Urls[0]
format := mail.MediaComponent.Images[0].Fmt
body := &strings.Builder{} body := &strings.Builder{}
h2 := fmt.Sprintf("<h2>%v</h2>", mail.GetText()) h2 := fmt.Sprintf("<h2>%v</h2>", mail.GetText())
img := fmt.Sprintf("<img border=\"0\" src=\"%v\" alt=\"图片加载错误,请联系管理员\">", url) img := fmt.Sprintf("<img border=\"0\" src=\"%v\" alt=\"图片加载错误,请联系管理员\">", url)
@ -29,14 +30,15 @@ func SendRavenIQTestResult(mail *dbstruct.Email, address, password string) error
if err != nil { if err != nil {
return err return err
} }
attachName := fmt.Sprintf("测评结果.%v", format[:6])
m := gomail.NewMessage() m := gomail.NewMessage()
m.SetHeader("From", mail.GetFrom()) m.SetHeader("From", mail.GetFrom(), "心意到了官方")
m.SetHeader("To", mail.GetTo()) m.SetHeader("To", mail.GetTo())
m.SetHeader("Subject", mail.GetSubject()) m.SetHeader("Subject", mail.GetSubject())
m.SetBody("text/html", body.String()) m.SetBody("text/html", body.String())
m.Attach("测评结果", gomail.SetCopyFunc(func(w io.Writer) error { //设置邮件附件 第一个参数是附件名称 第二个参数是二进制文件流 m.Attach(attachName, gomail.SetCopyFunc(func(w io.Writer) error { //设置邮件附件 第一个参数是附件名称 第二个参数是二进制文件流
_, err := w.Write(attach) _, err := w.Write(attach)
return err return err
})) }))