mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-09 23:42:55 +01:00
Add base64 support in email parser
Implemented base64 encoding support in the email parser. This addition allows the parser to read and decode base64 encoded emails.
This commit is contained in:
parent
a3b3deb467
commit
54ccb80925
1 changed files with 11 additions and 0 deletions
11
eml.go
11
eml.go
|
@ -6,6 +6,7 @@ package mail
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/base64"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"mime"
|
"mime"
|
||||||
|
@ -151,6 +152,16 @@ func parseEMLBodyParts(pm *nm.Message, mbbuf *bytes.Buffer, m *Msg) error {
|
||||||
m.SetBodyString(TypeTextPlain, qpbuf.String())
|
m.SetBodyString(TypeTextPlain, qpbuf.String())
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
if cte == EncodingB64.String() {
|
||||||
|
m.SetEncoding(EncodingB64)
|
||||||
|
b64d := base64.NewDecoder(base64.StdEncoding, mbbuf)
|
||||||
|
b64buf := bytes.Buffer{}
|
||||||
|
if _, err := b64buf.ReadFrom(b64d); err != nil {
|
||||||
|
return fmt.Errorf("failed to read base64 body: %w", err)
|
||||||
|
}
|
||||||
|
m.SetBodyString(TypeTextPlain, b64buf.String())
|
||||||
|
break
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue