diff --git a/eml.go b/eml.go index 632102d..bc96c0a 100644 --- a/eml.go +++ b/eml.go @@ -178,9 +178,6 @@ func parseEMLHeaders(mh *nm.Header, m *Msg) error { for _, h := range commonHeaders { if v := mh.Get(h.String()); v != "" { m.SetGenHeader(h, v) - if strings.EqualFold(h.String(), "subject") { - fmt.Printf("SUBJECT: %s\n", m.GetGenHeader(HeaderSubject)[0]) - } } } @@ -204,7 +201,8 @@ func parseEMLBodyParts(pm *nm.Message, bodybuf *bytes.Buffer, m *Msg) error { if err := parseEMLBodyPlain(mediatype, pm, bodybuf, m); err != nil { return fmt.Errorf("failed to parse plain body: %w", err) } - case strings.EqualFold(mediatype, TypeMultipartAlternative.String()): + case strings.EqualFold(mediatype, TypeMultipartAlternative.String()), + strings.EqualFold(mediatype, "multipart/mixed"): if err := parseEMLMultipartAlternative(params, bodybuf, m); err != nil { return fmt.Errorf("failed to parse multipart/alternative body: %w", err) } @@ -261,7 +259,6 @@ func parseEMLMultipartAlternative(params map[string]string, bodybuf *bytes.Buffe _ = mpart.Close() return fmt.Errorf("failed to read multipart: %w", err) } - fmt.Printf("CTE: %+v", params) mpContentType, ok := mpart.Header[HeaderContentType.String()] if !ok { diff --git a/encoding.go b/encoding.go index 39c58e3..2187e5f 100644 --- a/encoding.go +++ b/encoding.go @@ -140,6 +140,8 @@ const ( const ( TypeAppOctetStream ContentType = "application/octet-stream" TypeMultipartAlternative ContentType = "multipart/alternative" + TypeMultipartMixed ContentType = "multipart/mixed" + TypeMultipartRelated ContentType = "multipart/related" TypePGPSignature ContentType = "application/pgp-signature" TypePGPEncrypted ContentType = "application/pgp-encrypted" TypeTextHTML ContentType = "text/html" diff --git a/encoding_test.go b/encoding_test.go index 4a3affc..86f686a 100644 --- a/encoding_test.go +++ b/encoding_test.go @@ -40,6 +40,18 @@ func TestContentType_String(t *testing.T) { "ContentType: application/octet-stream", TypeAppOctetStream, "application/octet-stream", }, + { + "ContentType: multipart/alternative", TypeMultipartAlternative, + "multipart/alternative", + }, + { + "ContentType: multipart/mixed", TypeMultipartMixed, + "multipart/mixed", + }, + { + "ContentType: multipart/related", TypeMultipartRelated, + "multipart/related", + }, { "ContentType: application/pgp-signature", TypePGPSignature, "application/pgp-signature", diff --git a/msgwriter.go b/msgwriter.go index b2ff118..377435e 100644 --- a/msgwriter.go +++ b/msgwriter.go @@ -89,11 +89,11 @@ func (mw *msgWriter) writeMsg(m *Msg) { } if m.hasMixed() { - mw.startMP("mixed", m.boundary) + mw.startMP(MIMEMixed, m.boundary) mw.writeString(DoubleNewLine) } if m.hasRelated() { - mw.startMP("related", m.boundary) + mw.startMP(MIMERelated, m.boundary) mw.writeString(DoubleNewLine) } if m.hasAlt() {