mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-22 13:50:49 +01:00
Fix in writeBody method which returned wrong bytes amounts for encoded message bodies
This commit is contained in:
parent
b6d90eac6a
commit
d6f131c36d
1 changed files with 7 additions and 4 deletions
11
msgwriter.go
11
msgwriter.go
|
@ -1,6 +1,7 @@
|
||||||
package mail
|
package mail
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
@ -251,12 +252,13 @@ func (mw *msgWriter) writeBody(f func(io.Writer) (int64, error), e Encoding) {
|
||||||
if mw.d > 0 {
|
if mw.d > 0 {
|
||||||
w = mw.pw
|
w = mw.pw
|
||||||
}
|
}
|
||||||
|
wbuf := bytes.Buffer{}
|
||||||
|
|
||||||
switch e {
|
switch e {
|
||||||
case EncodingQP:
|
case EncodingQP:
|
||||||
ew = quotedprintable.NewWriter(w)
|
ew = quotedprintable.NewWriter(&wbuf)
|
||||||
case EncodingB64:
|
case EncodingB64:
|
||||||
ew = base64.NewEncoder(base64.StdEncoding, w)
|
ew = base64.NewEncoder(base64.StdEncoding, &wbuf)
|
||||||
case NoEncoding:
|
case NoEncoding:
|
||||||
n, mw.err = f(w)
|
n, mw.err = f(w)
|
||||||
mw.n += n
|
mw.n += n
|
||||||
|
@ -265,7 +267,8 @@ func (mw *msgWriter) writeBody(f func(io.Writer) (int64, error), e Encoding) {
|
||||||
ew = quotedprintable.NewWriter(w)
|
ew = quotedprintable.NewWriter(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
n, mw.err = f(ew)
|
_, mw.err = f(ew)
|
||||||
mw.n += int64(n)
|
|
||||||
mw.err = ew.Close()
|
mw.err = ew.Close()
|
||||||
|
n, mw.err = io.Copy(w, &wbuf)
|
||||||
|
mw.n += n
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue