gomail 中文附件名乱码问题处理


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
        }
    }
}

 

上一篇:调试mysql 插件命令


下一篇:python测试开发django-30.发送附件EmailMessage