{"_id":"mailparser-mit","_rev":"4-944679dc7ac0f977989347a418b73cba","name":"mailparser-mit","description":"MIT-licensed asynchronous and non-blocking parser for mime encoded e-mail messages","dist-tags":{"latest":"1.0.0"},"versions":{"0.6.2":{"name":"mailparser-mit","description":"MIT-licensed asynchronous and non-blocking parser for mime encoded e-mail messages","version":"0.6.2","author":{"name":"Andris Reinman"},"maintainers":[{"name":"Ross Johnson","email":"ross@mazira.com"}],"repository":{"type":"git","url":"git+ssh://git@github.com/mazira/mailparser-mit.git"},"scripts":{"test":"nodeunit test/"},"main":"./lib/mailparser","license":"MIT","dependencies":{"mimelib":"^0.3.0","encoding":"^0.1.12","mime":"^1.3.4","uue":"^3.1.0"},"devDependencies":{"nodeunit":"^0.10.2"},"keywords":["mailparser","emailparser","mail-parser","email-parser","e-mail-parser","mime-parser","mime-message","mime-message-parser","email","e-mail","mime","parser"],"gitHead":"473cfbeb785528933f5d2a6ce3d6c09708eedcb2","bugs":{"url":"https://github.com/mazira/mailparser-mit/issues"},"homepage":"https://github.com/mazira/mailparser-mit#readme","_id":"mailparser-mit@0.6.2","_shasum":"5dc44071b3322756f04b2cf0f8179b41399ea0ee","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.8.0","_npmUser":{"name":"rossj","email":"ross@mazira.com"},"dist":{"shasum":"5dc44071b3322756f04b2cf0f8179b41399ea0ee","tarball":"https://registry.npmjs.org/mailparser-mit/-/mailparser-mit-0.6.2.tgz","integrity":"sha512-K5K8Cb1Lwnhc0FA4m/w4scnk3IMMtjNCUEioaN1EYkxGhR5990Ds6XaFZglBB6qHIjeCl/kQn5kQ7HNwvcokzg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBmjTv8Ym+AJ0+vLyDhLwE+YdZhrw8/oXzeuL7erRNQUAiEAl3A9faRluobmmhiaMuTeXf7qrGPpYGscBViML0QqYiw="}]},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/mailparser-mit-0.6.2.tgz_1492019724926_0.30327122774906456"},"directories":{}},"1.0.0":{"name":"mailparser-mit","description":"MIT-licensed asynchronous and non-blocking parser for mime encoded e-mail messages","version":"1.0.0","author":{"name":"Andris Reinman"},"maintainers":[{"name":"rossj","email":"ross@mazira.com"}],"repository":{"type":"git","url":"git+ssh://git@github.com/mazira/mailparser-mit.git"},"scripts":{"test":"mocha --recursive --reporter list"},"main":"./lib/mailparser","license":"MIT","dependencies":{"addressparser":"^1.0.1","iconv-lite":"~0.4.24","mime":"^1.6.0","uue":"^3.1.0"},"devDependencies":{"chai":"4.2.0","iconv":"2.3.2","mocha":"5.2.0"},"keywords":["mailparser","emailparser","mail-parser","email-parser","e-mail-parser","mime-parser","mime-message","mime-message-parser","email","e-mail","mime","parser"],"gitHead":"e2ea9874a498a98382699dc3e9aaca2b8ac56598","bugs":{"url":"https://github.com/mazira/mailparser-mit/issues"},"homepage":"https://github.com/mazira/mailparser-mit#readme","_id":"mailparser-mit@1.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.14.2","_npmUser":{"name":"rossj","email":"ross@mazira.com"},"dist":{"integrity":"sha512-sckRITNb3VCT1sQ275g47MAN786pQ5lU20bLY5f794dF/ARGzuVATQ64gO13FOw8jayjFT10e5ttsripKGGXcw==","shasum":"19df8436c2a02e1d34a03ec518a2eb065e0a94a4","tarball":"https://registry.npmjs.org/mailparser-mit/-/mailparser-mit-1.0.0.tgz","fileCount":18,"unpackedSize":334901,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcaDjCCRA9TVsSAnZWagAAeaMP/R88Xp3r8RvM/a2tS045\nrhTeY4QigVpIiqkd09wJYKPrBbhJbPqECqF6bBCD6E0jP8rmrC6+tA3dBVcv\nsl0mKy4j8n/naTwQFgVitU2mwzNexVYAiU0628fhknVH48oApxMgeYsUNvAF\nSzk7OoMwcluC2quS9gkq1NAT8jBPfvQ0GM7UZF/5/U1OCRB3AjyZtByGYNDj\nOiaGBwAJO81+KVdY+zpHNobVfeJzJzfqW/lwJkxMr0MVasIljPlt+cwU907b\nv9DqYKXm1wBcbfaNH2TlUxwz5C8CA6Bty674aGSjn80+HVzl+pGUB3UeLBBA\ngrz0LZ9m5BCOs/f/T89Pu1ptPRmF+cy9b3+qT1T5PhfH4mmfmcwEv5EDXMcw\njPvNHBExoIQUkElTDKfVn1tLuvK8w6TvKpqjG7Ph/wYq88AolHH2B9kwWbaI\nNwUTn/mGmjWB2oA1xG7USdjI8rJTI7z3t22owUK0PzWWyJijg276ETxqPrnq\nPRO5yNuIGwLZMUJbr0LFFCwqk0OG0MgCGap/rM8/VDOT8ru+ME8Fq+rZ3+1E\nR1JsaIh9uJT2hcrLftnkqdiyqzVGeq7o+o52TLmHgFAwUQrPus7DljHFwVee\ntH4rVH3T1/S77c3gX7DwphP8vd5qNNE5Z7CgkAf7O9+YAmUTBZw7MTWF4kFk\nSqYY\r\n=7MOu\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBz2teGZv1B7Fua9+jz+CWMpV+RcZw+FbE9g2wXtXQt3AiEArUhJ1ueKm6PMwZnWeh2ggOCI+GRDFTvMtnGKZbRMJas="}]},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mailparser-mit_1.0.0_1550334146223_0.513788983792975"},"_hasShrinkwrap":false}},"readme":"# MailParser-MIT\n\n[![NPM version](https://badge.fury.io/js/mailparser-mit.svg)](http://badge.fury.io/js/mailparser-mit)\n\n**MailParser-MIT** is an asynchronous and non-blocking parser for\n[node.js](http://nodejs.org) to parse mime encoded e-mail messages.\nHandles even large attachments with ease - attachments can be parsed\nin chunks and streamed if needed.\n\n## Community version\n\nThis module is a fork of Andris Reinman's [MailParser](https://github.com/nodemailer/mailparser)\nmodule, which recently switched licenses during a large update. I will continue to update and\nmaintain this fork and keep it MIT licensed.\n\nFor easier maintenance, I have also started to move some dependency code into this project from Andris's other projects.\nSo far I have incorporated code from the latest MIT-licensed versions of\n[libmime](https://github.com/nodemailer/libmime) and [libpq](https://github.com/nodemailer/libqp).\n\nBecause I've accepted the part of me that wants to fix things that aren't broken, I plan to:\n- Convert to TypeScript\n- Separate into a cascade of Stream processors, for more flexibility\n- Add support for RTF bodies, including RTF-encoded HTML\n- Add more test cases, especially for exotic encodings\n- Continue support for [iconv-lite](https://github.com/ashtuchkin/iconv-lite) and [iconv](https://github.com/bnoordhuis/node-iconv)\n\n## Now accepting and test cases and pull requests!\n\nDo you have emails that **MailParser-MIT** fails to process? Please open an issue and I will take a look. If the test emails are sensitive, you can email them to me at ross@mazira.com, and I will try to generate a simple MIT-licensed test case for inclusion in this repository.\n\n## Overview\n\n**MailParser-MIT** parses raw source of e-mail messages into a structured object.\n\nNo need to worry about charsets or decoding *quoted-printable* or\n*base64* data, **MailParser-MIT** does all of it for you. All the textual output\nfrom **MailParser-MIT** (subject line, addressee names, message body) is always UTF-8.\n\nFor a 25MB e-mail it takes less than a second to parse if attachments are not streamed but buffered and about 3-4 seconds if they are streamed. Expect high RAM usage though if you do not stream the attachments.\n\nIf you want to send e-mail instead of parsing it, check out my other module [Nodemailer](https://github.com/andris9/Nodemailer).\n\n### ICONV NOTICE\n\nSince v0.4 `node-iconv` is not included by default as a dependency. If you need to support encodings not covered by `iconv-lite` you should add `iconv` as a dependency to your own project so `mailparser-mit` could pick it up.\n\n## Installation\n\n    npm install mailparser-mit\n\n## Usage\n\nRequire MailParser module\n```javascript\nvar MailParser = require(\"mailparser-mit\").MailParser;\n```\nCreate a new MailParser object\n```javascript\nvar mailparser = new MailParser([options]);\n```\nOptions parameter is an object with the following properties:\n\n  * **debug** - if set to true print all incoming lines to console\n  * **streamAttachments** - if set to true, stream attachments instead of including them\n  * **unescapeSMTP** - if set to true replace double dots in the beginning of the file\n  * **defaultCharset** - the default charset for *text/plain* and *text/html* content, if not set reverts to *Latin-1*\n  * **showAttachmentLinks** - if set to true, show inlined attachment links `<a href=\"cid:...\">filename</a>`\n\nMailParser object is a writable Stream - you can pipe directly\nfiles to it or you can send chunks with `mailparser.write`\n\nWhen the headers have received, \"headers\" is emitted. The headers have not been pre-processed (except that mime words have been converted to UTF-8 text).\n\n```javascript\nmailparser.on(\"headers\", function(headers){\n    console.log(headers.received);\n});\n```\nWhen the parsing ends an `'end'` event is emitted which has an\nobject with parsed e-mail structure as a parameter.\n\n```javascript\nmailparser.on(\"end\", function(mail){\n    mail; // object structure for parsed e-mail\n});\n```\n### Parsed mail object\n\n  * **headers** - unprocessed headers in the form of - `{key: value}` - if there were multiple fields with the same key then the value is an array\n  * **from** - an array of parsed `From` addresses - `[{address:'sender@example.com',name:'Sender Name'}]` (should be only one though)\n  * **to** - an array of parsed `To` addresses\n  * **cc** - an array of parsed `Cc` addresses\n  * **bcc** - an array of parsed 'Bcc' addresses\n  * **subject** - the subject line\n  * **references** - an array of reference message id values (not set if no reference values present)\n  * **inReplyTo** - an array of In-Reply-To message id values (not set if no in-reply-to values present)\n  * **priority** - priority of the e-mail, always one of the following: *normal* (default), *high*, *low*\n  * **text** - text body\n  * **html** - html body\n  * **date** - date field as a `Date()` object. If date could not be resolved or is not found this field is not set. Check the original date string from `headers.date`\n  * **attachments** - an array of attachments\n\n### Decode a simple e-mail\n\nThis example decodes an e-mail from a string\n\n```javascript\nvar MailParser = require(\"mailparser-mit\").MailParser;\nvar mailparser = new MailParser();\n\nvar email = \"From: 'Sender Name' <sender@example.com>\\r\\n\"+\n            \"To: 'Receiver Name' <receiver@example.com>\\r\\n\"+\n            \"Subject: Hello world!\\r\\n\"+\n            \"\\r\\n\"+\n            \"How are you today?\";\n\n// setup an event listener when the parsing finishes\nmailparser.on(\"end\", function(mail_object){\n    console.log(\"From:\", mail_object.from); //[{address:'sender@example.com',name:'Sender Name'}]\n    console.log(\"Subject:\", mail_object.subject); // Hello world!\n    console.log(\"Text body:\", mail_object.text); // How are you today?\n});\n\n// send the email source to the parser\nmailparser.write(email);\nmailparser.end();\n```\n### Pipe file to MailParser\n\nThis example pipes a `readableStream` file to **MailParser**\n```javascript\nvar MailParser = require(\"mailparser\").MailParser;\nvar mailparser = new MailParser();\nvar fs = require(\"fs\");\n\nmailparser.on(\"end\", function(mail_object){\n    console.log(\"Subject:\", mail_object.subject);\n});\n\nfs.createReadStream(\"email.eml\").pipe(mailparser);\n```\n### Attachments\n\nBy default any attachment found from the e-mail will be included fully in the\nfinal mail structure object as Buffer objects. With large files this might not\nbe desirable so optionally it is possible to redirect the attachments to a Stream\nand keep only the metadata about the file in the mail structure.\n\n```javascript\nmailparser.on(\"end\", function(mail_object){\n    mail_object.attachments.forEach(function(attachment){\n        console.log(attachment.fileName);\n    });\n});\n```\n#### Default behavior\n\nBy default attachments will be included in the attachment objects as Buffers.\n```javascript\nattachments = [{\n    contentType: 'image/png',\n    fileName: 'image.png',\n    contentDisposition: 'attachment',\n    contentId: '5.1321281380971@localhost',\n    transferEncoding: 'base64',\n    length: 126,\n    generatedFileName: 'image.png',\n    checksum: 'e4cef4c6e26037bcf8166905207ea09b',\n    content: <Buffer ...>\n}];\n```\nThe property `generatedFileName` is usually the same as `fileName` but if several\ndifferent attachments with the same name exist or there is no `fileName` set, an\nunique name is generated.\n\nProperty `content` is always a Buffer object (or SlowBuffer on some occasions)\n\n#### Attachment streaming\n\nAttachment streaming can be used when providing an optional options parameter\nto the `MailParser` constructor.\n```javascript\nvar mp = new MailParser({\n    streamAttachments: true\n}\n```\nThis way there will be no `content` property on final attachment objects\n(but the other fields will remain).\n\nTo catch the streams you should listen for `attachment` events on the MailParser\nobject. The parameter provided includes file information (`contentType`,\n`fileName`, `contentId`) and a readable Stream object `stream`.\n```javascript\nvar mp = new MailParser({\n    streamAttachments: true\n}\n\nmp.on(\"attachment\", function(attachment, mail){\n    var output = fs.createWriteStream(attachment.generatedFileName);\n    attachment.stream.pipe(output);\n});\n```\n`generatedFileName` is unique for the parsed mail - if several attachments with\nthe same name exist, `generatedFileName` is updated accordingly. Also there\nmight not be `fileName` parameter at all, so it is better to rely on\n`generatedFileName`.\n\n#### Testing attachment integrity\n\nAttachment objects include `length` property which is the length of the attachment\nin bytes and `checksum` property which is a `md5` hash of the file.\n\n### Running tests\n\nInstall **MailParser-MIT** with dev dependencies\n```bash\nnpm install --dev mailparser-mit\n```\nAnd then run\n```bash\nnpm test mailparser-mit\n```\nThere aren't many tests yet but basics should be covered.\n\n## Issues\n\n**S/MIME**\n\nCurrently it is not possible to verify signed content as the incoming text is\nsplit to lines when parsing and line ending characters are not preserved. One\ncan assume it is always \\r\\n but this might not be always the case.\n\n**Seeking**\n\nDue to the line based parsing it is also not possible to explicitly state\nthe beginning and ending bytes of the attachments for later source seeking.\nNode.js doesn't support the concept of seeking very well anyway.\n\n## License\n\n**MIT**\n","maintainers":[{"name":"rossj","email":"ross@mazira.com"}],"time":{"modified":"2022-06-19T15:28:12.731Z","created":"2017-04-12T17:55:26.881Z","0.6.2":"2017-04-12T17:55:26.881Z","1.0.0":"2019-02-16T16:22:26.327Z"},"homepage":"https://github.com/mazira/mailparser-mit#readme","keywords":["mailparser","emailparser","mail-parser","email-parser","e-mail-parser","mime-parser","mime-message","mime-message-parser","email","e-mail","mime","parser"],"repository":{"type":"git","url":"git+ssh://git@github.com/mazira/mailparser-mit.git"},"author":{"name":"Andris Reinman"},"bugs":{"url":"https://github.com/mazira/mailparser-mit/issues"},"license":"MIT","readmeFilename":"README.md"}