DusanKasan / parsemail

Simple email parsing for Golang
MIT License
212 stars 138 forks source link

Find Attachments, dont matter the content-type msg #25

Open marcospgmelo opened 4 years ago

marcospgmelo commented 4 years ago

I was trying to read an Email with a file.txt in attachment.

But, when the code run and see every kind of content-type, the searching for attachments was missed.

putting the search out of the "IF's chain", the message got all my attachment's.

As you can see the in case below:

_Subject: myTestFile txt To: test@example.com.br Content-Type: multipart/mixed; boundary="00000000000028c8b805affc4d1e"

--00000000000028c8b805affc4d1e Content-Type: multipart/alternative; boundary="00000000000028c8b705affc4d1c"

--00000000000028c8b705affc4d1c Content-Type: text/plain; charset="UTF-8"

--00000000000028c8b705affc4d1c Content-Type: text/html; charset="UTF-8"


--00000000000028c8b705affc4d1c-- --00000000000028c8b805affc4d1e Content-Type: text/plain; charset="US-ASCII"; name="myTestFile.txt" Content-Disposition: attachment; filename="myTestFile.txt" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: fkffi1n1v0

once the program search for the text/plain, the attachment was been ignored.