fix plain txt mails not parsing the mail body

the problem was that it was declared a byte array (txt) with
essentially size 0 and calling Read(txt). Since Read reads n
bytes up to sizeof(txt), nothing was being read.
This commit is contained in:
Guilherme Rugai Freire 2024-07-17 11:27:02 -03:00
parent 269c7614e1
commit 444e3d877e
No known key found for this signature in database
GPG Key ID: AC1D9B6E48E16AC1

View File

@ -94,15 +94,14 @@ func Parse_mail(m_data []byte, header_only bool) (Mail_obj, error) {
}
if content_type == "" || !strings.HasPrefix(mediaType, "multipart/") {
var txt []byte
_, err := mail_msg.Body.Read(txt)
txt_bytes, err := io.ReadAll(mail_msg.Body)
if err != nil {
return m, err
}
var body Mail_body
body.MimeType = PlainText
body.Data = string(txt)
body.Data = string(txt_bytes)
m.MediaType = NotMultipart
m.Body = append(m.Body, body)