Skip to content

Commit

Permalink
Find Attachments, dont matter the content-type msg
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospgmelo committed Sep 23, 2020
1 parent d916cfb commit 9e2f5b1
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions parsemail.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,14 @@ func parseMultipartMixed(msg io.Reader, boundary string) (textBody, htmlBody str
return textBody, htmlBody, attachments, embeddedFiles, err
}

if isAttachment(part) {
at, err := decodeAttachment(part)
if err != nil {
return textBody, htmlBody, attachments, embeddedFiles, err
}
attachments = append(attachments, at)
}

if contentType == contentTypeMultipartAlternative {
textBody, htmlBody, embeddedFiles, err = parseMultipartAlternative(part, params["boundary"])
if err != nil {
Expand All @@ -256,13 +264,6 @@ func parseMultipartMixed(msg io.Reader, boundary string) (textBody, htmlBody str
}

htmlBody += strings.TrimSuffix(string(ppContent[:]), "\n")
} else if isAttachment(part) {
at, err := decodeAttachment(part)
if err != nil {
return textBody, htmlBody, attachments, embeddedFiles, err
}

attachments = append(attachments, at)
} else {
return textBody, htmlBody, attachments, embeddedFiles, fmt.Errorf("Unknown multipart/mixed nested mime type: %s", contentType)
}
Expand Down Expand Up @@ -483,11 +484,11 @@ type Email struct {
ResentMessageID string

ContentType string
Content io.Reader
Content io.Reader

HTMLBody string
TextBody string

Attachments []Attachment
EmbeddedFiles []EmbeddedFile
}
}

0 comments on commit 9e2f5b1

Please sign in to comment.