Add handling for multipart/alternative content type

The EML parser now includes logic to manage 'multipart/alternative' content types. This adjustment is made within the section handling 'multipart/related' parts, allowing for better handling and parsing of varying content types.
This commit is contained in:
Winni Neessen 2024-06-28 13:28:09 +02:00
parent 84e6275cb2
commit fcc5209852
Signed by: wneessen
GPG key ID: 385AC9889632126E

4
eml.go
View file

@ -256,7 +256,9 @@ ReadNextPart:
// Multipart/related parts need to be parsed seperately // Multipart/related parts need to be parsed seperately
if contentTypeSlice, ok := multiPart.Header[HeaderContentType.String()]; ok && len(contentTypeSlice) == 1 { if contentTypeSlice, ok := multiPart.Header[HeaderContentType.String()]; ok && len(contentTypeSlice) == 1 {
contentType, _ := parseMultiPartHeader(contentTypeSlice[0]) contentType, _ := parseMultiPartHeader(contentTypeSlice[0])
if strings.EqualFold(contentType, TypeMultipartRelated.String()) { fmt.Printf("CONTENT-TYPE: %s\n", contentType)
if strings.EqualFold(contentType, TypeMultipartRelated.String()) ||
strings.EqualFold(contentType, TypeMultipartAlternative.String()) {
relatedPart := &netmail.Message{ relatedPart := &netmail.Message{
Header: netmail.Header(multiPart.Header), Header: netmail.Header(multiPart.Header),
Body: multiPart, Body: multiPart,