{"_id":"@ch4nn0n/email-forward-parser","name":"@ch4nn0n/email-forward-parser","dist-tags":{"latest":"1.4.2"},"versions":{"1.4.2":{"name":"@ch4nn0n/email-forward-parser","version":"1.4.2","description":"Parses forwarded emails and extract content","author":{"name":"Eliott Vincent","email":"eliott@crisp.chat"},"main":"lib/index.js","homepage":"https://github.com/crisp-oss/email-forward-parser","repository":{"type":"git","url":"git://github.com/crisp-oss/email-forward-parser.git"},"bugs":{"url":"https://github.com/crisp-oss/email-forward-parser/issues"},"scripts":{"test":"nodeunit ./test/index.js"},"devDependencies":{"nodeunit-x":"0.15.0"},"keywords":["parser","mail","email","forward"],"license":"MIT","gitHead":"753f5d02bb450140dee7d62a6fcad90ac2e12ec1","_id":"@ch4nn0n/email-forward-parser@1.4.2","_nodeVersion":"16.20.1","_npmVersion":"8.19.4","dist":{"integrity":"sha512-30t52ua4W7lnwPOB+Ngd8jSDBoLyZhCo5tLqyinc6kPcuToYTGtL6EH0shHWjIzLlBIWRyW65zw+HaJ9XWsBYg==","shasum":"f8778f755bb6b047cf0df2017da0a8f36482d8ab","tarball":"https://registry.npmjs.org/@ch4nn0n/email-forward-parser/-/email-forward-parser-1.4.2.tgz","fileCount":6,"unpackedSize":57297,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD+mkzY9JHIoRklvZwzEnoM3CP2QnnwA9cvr0sFP7loNgIgAc0i44l1uGg4lDkV0hPhHFA1jewHvFSIv4DZSUVNiz4="}]},"_npmUser":{"name":"ch4nn0n","email":"josh@channon.dev"},"directories":{},"maintainers":[{"name":"ch4nn0n","email":"josh@channon.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/email-forward-parser_1.4.2_1689665200152_0.19583339630275476"},"_hasShrinkwrap":false}},"time":{"created":"2023-07-18T07:26:40.065Z","1.4.2":"2023-07-18T07:26:40.293Z","modified":"2023-07-18T07:26:40.573Z"},"maintainers":[{"name":"ch4nn0n","email":"josh@channon.dev"}],"description":"Parses forwarded emails and extract content","homepage":"https://github.com/crisp-oss/email-forward-parser","keywords":["parser","mail","email","forward"],"repository":{"type":"git","url":"git://github.com/crisp-oss/email-forward-parser.git"},"author":{"name":"Eliott Vincent","email":"eliott@crisp.chat"},"bugs":{"url":"https://github.com/crisp-oss/email-forward-parser/issues"},"license":"MIT","readme":"# Email Forward Parser\n\n[![Test and Build](https://github.com/ch4nn0n/email-forward-parser/workflows/Test%20and%20Build/badge.svg?branch=master)](https://github.com/ch4nn0n/email-forward-parser/actions?query=workflow%3A%22Test+and+Build%22) [![Build and Release](https://github.com/ch4nn0n/email-forward-parser/workflows/Build%20and%20Release/badge.svg)](https://github.com/ch4nn0n/email-forward-parser/actions?query=workflow%3A%22Build+and+Release%22) [![NPM](https://img.shields.io/npm/v/@ch4nn0n/email-forward-parser.svg)](https://www.npmjs.com/package/@channon/email-forward-parser) [![Downloads](https://img.shields.io/npm/dt/@channon/email-forward-parser.svg)](https://www.npmjs.com/package/@channon/email-forward-parser)\n\nParses forwarded emails and extracts original content.\n\nThis library supports most common email clients and locales.\n\n## Motivation\nThe original project from [Crisp](https://crisp.chat/) [email-reply-parser](https://github.com/crisp-oss/email-forward-parser) relies on the [RE2](https://www.npmjs.com/package/re2) library, which is not available on all platforms, namely some serverless and browser environments. This fork is a pure javascript implementation of the same library.  \n\n## Features\n\n* Supported clients: Apple Mail, Gmail, Outlook Live / 365, Outlook 2013, Outlook 2019, New Outlook 2019, Yahoo Mail, Thunderbird, Missive, HubSpot, IONOS by 1 & 1\n* Supported locales: Croatian, Czech, Danish, Dutch, English, French, Finnish, German, Hungarian, Italian, Japanese, Norwegian, Polish, Portuguese (Brazil), Portuguese (Portugal), Romanian, Russian, Slovak, Spanish, Swedish, Turkish, Ukrainian\n\n## Usage\n\n```js\nconst EmailForwardParser = require(\"email-forward-parser\");\n\nconst result = new EmailForwardParser().read(MY_EMAIL_STRING);\n\nconsole.log(result.forwarded);\n// true\n```\n\n## API\n\n### Parse a forwarded email\n\n`read(body, subject)` checks whether an email was forwarded or not, and parses its original content (From, To, Cc, Subject, Date and Body):\n* `body` must be a string representing the email body (as returned by [mailparser](https://github.com/nodemailer/mailparser), for example)\n* `subject` must be a string representing the email subject. This parameter is optional, but recommended to improve the detection for some email clients (especially New Outlook 2019)\n\n```js\nconst EmailForwardParser = require(\"email-forward-parser\");\n\nconst result = new EmailForwardParser().read(MY_EMAIL_STRING, MY_SUBJECT_STRING);\n\nconsole.log(result);\n// {\n//   forwarded: true,\n//\n//   message: \"Praesent suscipit egestas hendrerit.\",\n//\n//   email: {\n//     body: \"Aenean quis diam urna.\",\n//\n//     from: {\n//       address: \"john.doe@acme.com\",\n//       name: \"John Doe\"\n//     },\n//     to: [{\n//       address: \"bessie.berry@acme.com\",\n//       name: \"Bessie Berry\"\n//     }],\n//     cc: [{\n//       address: \"walter.sheltan@acme.com\",\n//       name: \"Walter Sheltan\"\n//     }],\n//\n//     subject: \"Integer consequat non purus\",\n//     date: \"25 October 2021 at 11:17:21 EEST\"\n//   }\n// }\n```\n\n## How does it work?\n\nEmail forwarding (i.e. when you manually forward a copy of an email by clicking the \"Forward\" button in your email client) is not standardized by any RFC. Meaning that email clients are free to format the forwarded email the way they want.\n\nThere is no magic bullet to handle such disparities. The only viable solution is to rely on **regular expressions** (a lot!), to account for each email client's specificities:\n\nClient | Detectable via subject | Detectable via separator | Subject localized | Separator localized | All original information available | Original information localized | Other specificities\n--- | --- | --- | --- | --- | --- | --- | ---\nApple Mail | Yes | Yes | Yes | Yes | Yes | Yes | --\nGmail | Yes | Yes | No | No | Yes | Only some parts | --\nOutlook Live / 365 | Yes | Yes | Yes | No | Yes | No | --\nOutlook 2013 | Yes | No | ? | -- | ? | ? | --\nOutlook 2019 | Yes | Yes | No | Yes | No | Yes | The From and Date parts (only original information available) are embedded in the separator, rather than the body itself\nNew Outlook 2019 | Yes | No | Yes | -- | Yes | Yes | --\nYahoo Mail | Yes | Yes | No | Yes | Yes | Yes | The original information are all stuck to each other, without line breaks\nThunderbird | Yes | Yes | No | Yes | Yes | Yes | --\nMissive | Yes | Yes | No | No | Yes | No | --\nHubSpot | Yes | Yes | Yes | Yes | Yes | Yes | --\nIONOS by 1 & 1 | ? | Yes | ? | ? | Yes | ? | --\n\n## Contributing\n\nFeel free to fork this project and submit fixes. We may adapt your code to fit the codebase.\n\nYou can run unit tests using:\n\n```\nnpm test\n```\n\n## License\n\nemail-forward-parser is released under the MIT License. See the bundled LICENSE file for details.\n","readmeFilename":"README.md"}