From 444e3d877eb8cce6efe14e9c62c5ba87d74fd4c8 Mon Sep 17 00:00:00 2001 From: Guilherme Rugai Freire Date: Wed, 17 Jul 2024 11:27:02 -0300 Subject: [PATCH] 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. --- pkg/mail_utils/mail_utils.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/mail_utils/mail_utils.go b/pkg/mail_utils/mail_utils.go index f0687b3..3af78be 100644 --- a/pkg/mail_utils/mail_utils.go +++ b/pkg/mail_utils/mail_utils.go @@ -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)