When I send two attachments at the same time, the content of the A attachment will be overwritten by the content of the attachment B, and the content of the attachment B is empty
My code is as follows,i appreciate it.
func SendMail(subject, body string, to []string, file map[string]*os.File) {
user := "test@test.com"
password := "123456"
m := gomail.NewMessage()
m.SetHeaders(map[string][]string{
"From": {m.FormatAddress("test@test.com", "test")},
"To": to,
"Subject": {subject},
})
m.SetBody("text/html", body)
for fname, f := range file {
m.Attach(fname, gomail.SetCopyFunc(func(w io.Writer) error {
_, err := io.Copy(w, f)
defer f.Close()
return err
}))
}
d := gomail.NewDialer("test@test.com", 587, user, password)
d.TLSConfig = &tls.Config{InsecureSkipVerify: true}
if err := d.DialAndSend(m); err != nil {
log.Println(err)
}
When I send two attachments at the same time, the content of the A attachment will be overwritten by the content of the attachment B, and the content of the attachment B is empty My code is as follows,i appreciate it.
func SendMail(subject, body string, to []string, file map[string]*os.File) {
}
func main() {
}