mirror of
https://github.com/wneessen/go-mail.git
synced 2024-12-23 02:50:39 +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 (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"mime"
|
||||
|
@ -151,6 +152,16 @@ func parseEMLBodyParts(pm *nm.Message, mbbuf *bytes.Buffer, m *Msg) error {
|
|||
m.SetBodyString(TypeTextPlain, qpbuf.String())
|
||||
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:
|
||||
}
|
||||
return nil
|
||||
|
|
Loading…
Reference in a new issue