mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-09 23:42:55 +01:00
Another fix for the written byte counting, this time for parts (alt/attach/embed)
This commit is contained in:
parent
429c9a1883
commit
68049b568d
1 changed files with 11 additions and 3 deletions
10
msgwriter.go
10
msgwriter.go
|
@ -260,8 +260,11 @@ func (mw *msgWriter) writeBody(f func(io.Writer) (int64, error), e Encoding) {
|
||||||
case EncodingB64:
|
case EncodingB64:
|
||||||
ew = base64.NewEncoder(base64.StdEncoding, &wbuf)
|
ew = base64.NewEncoder(base64.StdEncoding, &wbuf)
|
||||||
case NoEncoding:
|
case NoEncoding:
|
||||||
n, mw.err = f(w)
|
_, mw.err = f(&wbuf)
|
||||||
|
n, mw.err = io.Copy(w, &wbuf)
|
||||||
|
if mw.d == 0 {
|
||||||
mw.n += n
|
mw.n += n
|
||||||
|
}
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
ew = quotedprintable.NewWriter(w)
|
ew = quotedprintable.NewWriter(w)
|
||||||
|
@ -270,5 +273,10 @@ func (mw *msgWriter) writeBody(f func(io.Writer) (int64, error), e Encoding) {
|
||||||
_, mw.err = f(ew)
|
_, mw.err = f(ew)
|
||||||
mw.err = ew.Close()
|
mw.err = ew.Close()
|
||||||
n, mw.err = io.Copy(w, &wbuf)
|
n, mw.err = io.Copy(w, &wbuf)
|
||||||
|
|
||||||
|
// Since the part writer uses the Write() method, we don't need to add the
|
||||||
|
// bytes twice
|
||||||
|
if mw.d == 0 {
|
||||||
mw.n += n
|
mw.n += n
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue