mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-22 13:50:49 +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
|
// Write writes the formated Msg into a give io.Writer
|
||||||
func (m *Msg) Write(w io.Writer) (int64, error) {
|
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)
|
mw.writeMsg(m)
|
||||||
return mw.n, mw.err
|
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
|
// msgWriter handles the I/O to the io.WriteCloser of the SMTP client
|
||||||
type msgWriter struct {
|
type msgWriter struct {
|
||||||
|
c Charset
|
||||||
d int8
|
d int8
|
||||||
|
en mime.WordEncoder
|
||||||
err error
|
err error
|
||||||
mpw [3]*multipart.Writer
|
mpw [3]*multipart.Writer
|
||||||
n int64
|
n int64
|
||||||
|
@ -125,7 +127,8 @@ func (mw *msgWriter) addFiles(fl []*File, a bool) {
|
||||||
if mt == "" {
|
if mt == "" {
|
||||||
mt = "application/octet-stream"
|
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 {
|
if _, ok := f.getHeader(HeaderContentTransferEnc); !ok {
|
||||||
|
@ -137,7 +140,8 @@ func (mw *msgWriter) addFiles(fl []*File, a bool) {
|
||||||
if a {
|
if a {
|
||||||
d = "attachment"
|
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 {
|
if !a {
|
||||||
|
|
Loading…
Reference in a new issue