diff --git a/internal/mail/message.go b/internal/mail/message.go index ae1fd1b..c07dc3b 100644 --- a/internal/mail/message.go +++ b/internal/mail/message.go @@ -3,6 +3,7 @@ package mail import ( "bytes" + "fmt" "io" "strings" @@ -72,13 +73,19 @@ func ParseMessage(uid uint32, raw []byte) (Message, error) { case *mail.InlineHeader: ct, _, _ := hdr.ContentType() if strings.HasPrefix(ct, "text/plain") && m.BodyText == "" { - b, _ := io.ReadAll(part.Body) + b, err := io.ReadAll(part.Body) + if err != nil { + return Message{}, fmt.Errorf("read message part: %w", err) + } m.BodyText = string(b) } case *mail.AttachmentHeader: name, _ := hdr.Filename() ct, _, _ := hdr.ContentType() - b, _ := io.ReadAll(part.Body) + b, err := io.ReadAll(part.Body) + if err != nil { + return Message{}, fmt.Errorf("read message part: %w", err) + } m.Attachments = append(m.Attachments, Attachment{ Name: name, Size: len(b), MIME: ct, Content: b, })