Merge branch 'coypoop-master'
diff --git a/parsemail.go b/parsemail.go
index d37e82c..1cde6c8 100644
--- a/parsemail.go
+++ b/parsemail.go
@@ -241,6 +241,13 @@
if err != nil {
return textBody, htmlBody, attachments, embeddedFiles, err
}
+ } else if contentType == contentTypeTextPlain {
+ ppContent, err := ioutil.ReadAll(part)
+ if err != nil {
+ return textBody, htmlBody, attachments, embeddedFiles, err
+ }
+
+ textBody += strings.TrimSuffix(string(ppContent[:]), "\n")
} else if isAttachment(part) {
at, err := decodeAttachment(part)
if err != nil {
diff --git a/parsemail_test.go b/parsemail_test.go
index 6796a29..944c0b7 100644
--- a/parsemail_test.go
+++ b/parsemail_test.go
@@ -275,6 +275,25 @@
contentType: `image/jpeg; x-unix-mode=0644; name="image.gif"`,
content: `GIF89a;`,
},
+ 9: {
+ contentType: `multipart/mixed; boundary="0000000000007e2bb40587e36196"`,
+ mailData: textPlainInMultipart,
+ subject: "Re: kern/54143 (virtualbox)",
+ from: []mail.Address{
+ {
+ Name: "Rares",
+ Address: "rares@example.com",
+ },
+ },
+ to: []mail.Address{
+ {
+ Name: "",
+ Address: "bugs@example.com",
+ },
+ },
+ date: parseDate("Fri, 02 May 2019 11:25:35 +0300"),
+ textBody: `plain text part`,
+ },
}
for index, td := range testData {
@@ -626,6 +645,19 @@
--------------C70C0458A558E585ACB75FB4--
`
+var textPlainInMultipart = `From: Rares <rares@example.com>
+Date: Thu, 2 May 2019 11:25:35 +0300
+Subject: Re: kern/54143 (virtualbox)
+To: bugs@example.com
+Content-Type: multipart/mixed; boundary="0000000000007e2bb40587e36196"
+
+--0000000000007e2bb40587e36196
+Content-Type: text/plain; charset="UTF-8"
+
+plain text part
+--0000000000007e2bb40587e36196--
+`
+
var rfc5322exampleA11 = `From: John Doe <jdoe@machine.example>
Sender: Michael Jones <mjones@machine.example>
To: Mary Smith <mary@example.net>