mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-09 15:32:54 +01:00
Attachment names should probably be encoded
This commit is contained in:
parent
ce1c37bd16
commit
a87577d388
2 changed files with 7 additions and 3 deletions
2
msg.go
2
msg.go
|
@ -461,7 +461,7 @@ func (m *Msg) Reset() {
|
|||
|
||||
// Write writes the formated Msg into a give io.Writer
|
||||
func (m *Msg) Write(w io.Writer) (int64, error) {
|
||||
mw := &msgWriter{w: w}
|
||||
mw := &msgWriter{w: w, c: m.charset, en: m.encoder}
|
||||
mw.writeMsg(m)
|
||||
return mw.n, mw.err
|
||||
}
|
||||
|
|
|
@ -18,7 +18,9 @@ const MaxHeaderLength = 76
|
|||
|
||||
// msgWriter handles the I/O to the io.WriteCloser of the SMTP client
|
||||
type msgWriter struct {
|
||||
c Charset
|
||||
d int8
|
||||
en mime.WordEncoder
|
||||
err error
|
||||
mpw [3]*multipart.Writer
|
||||
n int64
|
||||
|
@ -125,7 +127,8 @@ func (mw *msgWriter) addFiles(fl []*File, a bool) {
|
|||
if mt == "" {
|
||||
mt = "application/octet-stream"
|
||||
}
|
||||
f.setHeader(HeaderContentType, fmt.Sprintf(`%s; name="%s"`, mt, f.Name))
|
||||
f.setHeader(HeaderContentType, fmt.Sprintf(`%s; name="%s"`, mt,
|
||||
mw.en.Encode(mw.c.String(), f.Name)))
|
||||
}
|
||||
|
||||
if _, ok := f.getHeader(HeaderContentTransferEnc); !ok {
|
||||
|
@ -137,7 +140,8 @@ func (mw *msgWriter) addFiles(fl []*File, a bool) {
|
|||
if a {
|
||||
d = "attachment"
|
||||
}
|
||||
f.setHeader(HeaderContentDisposition, fmt.Sprintf(`%s; filename="%s"`, d, f.Name))
|
||||
f.setHeader(HeaderContentDisposition, fmt.Sprintf(`%s; filename="%s"`, d,
|
||||
mw.en.Encode(mw.c.String(), f.Name)))
|
||||
}
|
||||
|
||||
if !a {
|
||||
|
|
Loading…
Reference in a new issue