From 1a528f12b064890171f69077a35a6796076051fd Mon Sep 17 00:00:00 2001 From: ioito Date: Wed, 8 Mar 2023 11:57:41 +0800 Subject: [PATCH] fix(notify): attachment name --- pkg/notify/sender/email.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/notify/sender/email.go b/pkg/notify/sender/email.go index 353fb51fc4..97aaba0362 100644 --- a/pkg/notify/sender/email.go +++ b/pkg/notify/sender/email.go @@ -17,7 +17,9 @@ package sender import ( "crypto/tls" "encoding/base64" + "fmt" "io" + "mime" "net/http" "net/url" "time" @@ -90,6 +92,11 @@ func (emailSender *SEmailSender) Send(args api.SendParams) error { _, err := w.Write([]byte("Content-Type: " + attach.Mime)) return errors.Wrap(err, "WriteMime") }), + gomail.SetHeader(map[string][]string{ + "Content-Disposition": { + fmt.Sprintf(`attachment; filename="%s"`, mime.QEncoding.Encode("UTF-8", attach.Filename)), + }, + }), gomail.SetCopyFunc(func(w io.Writer) error { contBytes, err := base64.StdEncoding.DecodeString(attach.Base64Content) if err != nil {