mat-sz / letterparser

✉️ Isomorphic e-mail parser (with MIME support) written in TypeScript.
BSD 3-Clause Clear License
36 stars 4 forks source link

Handling of Multipart message fails #1

Closed dceejay closed 3 years ago

dceejay commented 3 years ago

Hi,

If a send a simple multipart message and catch it with your micromta code - then pass it to letterparser It fails to decode the parts...

Here is the incoming multipart

{
  recipients: [ 'Mike@foo.bar' ],
  sender: 'me@myserver.com',
  message: 'Content-Type: multipart/mixed; boundary="--_NmP-79d22631bd047a69-Part_1"\r\n' +
    'From: me@myserver.com\r\n' +
    'To: Mike@foo.bar\r\n' +
    'Subject: New Subject\r\n' +
    'Message-ID: <4392b49b-91b4-fad0-34a5-115a5cc96fa6@myserver.com>\r\n' +
    'Date: Tue, 13 Oct 2020 19:12:21 +0000\r\n' +
    'MIME-Version: 1.0\r\n' +
    '\r\n' +
    '----_NmP-79d22631bd047a69-Part_1\r\n' +
    'Content-Type: text/plain; charset=utf-8\r\n' +
    'Content-Transfer-Encoding: 7bit\r\n' +
    '\r\n' +
    'More words I have an attachment\r\n' +
    '----_NmP-79d22631bd047a69-Part_1\r\n' +
    'Content-Type: text/plain; name="c:/temp/foo.txt"\r\n' +
    'Content-Transfer-Encoding: base64\r\n' +
    'Content-Disposition: attachment; filename="c:/temp/foo.txt"\r\n' +
    '\r\n' +
    'U29tZSBzbWFsbCB3b3JkcyB0byB0ZXN0IGF0dGFjaG1lbnQ=\r\n' +
    '----_NmP-79d22631bd047a69-Part_1--'
}

If I add some debug I can that for some reason in line 43 of parser.js you do

    var split = value
        .toLowerCase()

which then ends up with parameters['boundary'] being all lower case which for the message above you can see is not the case... so I'm not sure why you make it all lowercase ?

However If I remove that then I do get a return object with multiple "body"s - but they are both empty strings.... so something else is also not working...

Many thanks

PS the email above was generated using nodemailer, in case that matters.

mat-sz commented 3 years ago

Thank you for your bug report and investigation, I will take a look at this right now.

mat-sz commented 3 years ago

Resolved with 0.0.3.