mat-sz / letterparser

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

Unable to parse emails from outlook #2

Closed arunrreddy closed 3 years ago

arunrreddy commented 3 years ago

I am unable to parse emails from outlook. This is the stack trace for the corresponding. Error: Unexpected space at the beginning of line 51 at parseHeaders (/home/example/node_modules/letterparser/lib/parser.js:95:23) at Object.parseBody (/home/example/node_modules/letterparser/lib/parser.js:135:21) at parse (/home/example/node_modules/letterparser/lib/index.js:32:30)

mat-sz commented 3 years ago

Could you, please, share an example of such message?

arunrreddy commented 3 years ago

It has some sensitive info. Can I send it over mail?

mat-sz commented 3 years ago

Got it! Thanks. Will work on the issue tomorrow.

arunrreddy commented 3 years ago

ok cool. Thanks a ton.

arunrreddy commented 3 years ago

Since headers are failed to being passed sometimes, this could be a good strategy if the existing logic ends in an error. If a header name is found on a specific line and the header value condition check fails, search the immediate next line for a value and capture that as the header value, otherwise throw any error.

mat-sz commented 3 years ago

Patch published with version 0.0.4.

arunrreddy commented 3 years ago

Tried 0.0.4 version. Getting the same error still. It fails to parse the below lines.

Date: Fri, 30 Oct 2020 19:28:52 +0000 Message-ID: DM5PR03MB32105C813B31150ED43297499B150@DM5PR03MB3210.namprd03.prod.outlook.com References: 01000175757e79fd-1e262982-ff5a-4ace-b0c6-267c0d2a12cf-000000@email.amazonses.com In-Reply-To: 01000175757e79fd-1e262982-ff5a-4ace-b0c6-267c0d2a12cf-000000@email.amazonses.com

arunrreddy commented 3 years ago

I can see that there is a space before the three keys on the new line as well.

mat-sz commented 3 years ago

The raw email you've sent me parses just fine on 0.0.4. (Saved it to file, read using readFileSync and parsed using letterparser.parse()).

arunrreddy commented 3 years ago

Still failing with the below error. "err":{"message":"Unexpected space at the beginning of line 51","name":"Error","stack":"Error: Unexpected space at the beginning of line 51\n at parseHeaders (/root/workspace/example-api/node_modules/letterparser/lib/parser.js:95:23)\n at Object.parseBody (/root/workspace/example-api/node_modules/letterparser/lib/parser.js:135:21)\n at parse (/root/workspace/example-api/node_modules/letterparser/lib/index.js:32:30)\n