Skip to content

Commit 47ee9e8

Browse files
ischMario Hros
isch
authored and
Mario Hros
committed
Small fix
1 parent abb3b23 commit 47ee9e8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

parsemail.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,15 @@ func parseContentType(contentTypeHeader string) (contentType string, params map[
107107
}
108108

109109
func parseAttachmentOnlyEmail(body io.Reader, header mail.Header) (attachments []Attachment, err error) {
110-
attachmentData, err := decodeContent(body, header.Get("Content-Transfer-Encoding"))
111110
contentDisposition := header.Get("Content-Disposition")
112111

113-
if err != nil {
114-
return attachments, err
115-
}
116-
117112
if len(contentDisposition) > 0 && strings.Contains(contentDisposition, "attachment;") {
113+
114+
attachmentData, err := decodeContent(body, header.Get("Content-Transfer-Encoding"))
115+
if err != nil {
116+
return attachments, err
117+
}
118+
118119
fileName := strings.Replace(contentDisposition, "attachment; filename=\"", "", -1)
119120
fileName = strings.TrimRight(fileName, "\"")
120121

@@ -123,6 +124,7 @@ func parseAttachmentOnlyEmail(body io.Reader, header mail.Header) (attachments [
123124
ContentType: "application/octet-stream",
124125
Data: attachmentData,
125126
}
127+
126128
attachments = append(attachments, at)
127129
}
128130

0 commit comments

Comments
 (0)