1 m.Attach(item, gomail.Rename(fileName), gomail.SetHeader(map[string][]string{ 2 "Content-Disposition": []string{ 3 fmt.Sprintf(`attachment; filename="%s"`, mime.QEncoding.Encode("UTF-8", fileName)), 4 }, 5 })) //添加附件,处理附件名乱码问题
// Attach attaches the files to the email.
func (m *Message) Attach(filename string, settings ...FileSetting) { m.attachments = m.appendFile(m.attachments, filename, settings) }
// Mandatory headers are automatically added if they are not set when sending // the email. func SetHeader(h map[string][]string) FileSetting { return func(f *file) { for k, v := range h { f.Header[k] = v } } }