Important
This module is in maintenance mode. It will continue to receive security updates and critical bug fixes, but no new features or feature changes will be added. For new projects, please consider using PostalMime, which works in both Node.js and browser environments.
Advanced email parser for Node.js. Everything is handled as a stream which should make it able to parse even very large messages (100MB+) with relatively low overhead.
First install the module from npm:
$ npm install mailparser
next import the mailparser object into your script:
const mailparser = require('mailparser');See mailparser homepage for documentation and terms.
simpleParserreplacescid:image references in the HTML withdata:URLs. The total length of the URLs written into the HTML is capped by themaxInlinedImagesSizeoption (default 20 MB, counted in characters of the inserted URLs). References past the cap stay ascid:links. The same cap applies to URLs returned from a customupdateImageLinks()callback.simpleParsercalls its callback, or settles its promise, exactly once. WhenMailParserreports a non-fatal error and then finishes parsing, that error is what the caller receives.- HTML that can not be converted to text (longer than
maxHtmlLengthToParse, nested deeper than 1000 levels, or rejected by html-to-text) does not fail the message.textis empty,htmlis kept, and the reason is set astextConversionErroron the result (and on thetextobjectMailParseremits).
Licensed under MIT
