npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

email-forward-parser

v1.6.0

Published

Parses forwarded emails and extract content

Downloads

3,269

Readme

Email Forward Parser

Test and Build Build and Release NPM Downloads

Parses forwarded emails and extracts original content.

This library supports most common email clients and locales.

😘 Maintainer: @eliottvincent

Who uses it?

👋 You use this library and you want to be listed there? Contact us.

Features

This library is used at Crisp everyday with around 1 million inbound emails.

  • Supported clients: Apple Mail, Gmail, Outlook Live / 365, Outlook 2013, Outlook 2019, New Outlook 2019, Yahoo Mail, Thunderbird, Missive, HubSpot, IONOS by 1 & 1, MailMate
  • 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

Usage

const EmailForwardParser = require("email-forward-parser");

const result = new EmailForwardParser().read(MY_EMAIL_STRING);

console.log(result.forwarded);
// true

API

Parse a forwarded email

read(body, subject) checks whether an email was forwarded or not, and parses its original content (From, To, Cc, Subject, Date and Body):

  • body must be a string representing the email body (as returned by mailparser, for example)
  • 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)
const EmailForwardParser = require("email-forward-parser");

const result = new EmailForwardParser().read(MY_EMAIL_STRING, MY_SUBJECT_STRING);

console.log(result);
// {
//   forwarded: true,
//
//   message: "Praesent suscipit egestas hendrerit.",
//
//   email: {
//     body: "Aenean quis diam urna.",
//
//     from: {
//       address: "[email protected]",
//       name: "John Doe"
//     },
//     to: [{
//       address: "[email protected]",
//       name: "Bessie Berry"
//     }],
//     cc: [{
//       address: "[email protected]",
//       name: "Walter Sheltan"
//     }],
//
//     subject: "Integer consequat non purus",
//     date: "25 October 2021 at 11:17:21 EEST"
//   }
// }

How does it work?

Email 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.

There 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:

Client | Detectable via subject | Detectable via separator | Subject localized | Separator localized | All original information available | Original information localized | Other specificities --- | --- | --- | --- | --- | --- | --- | --- Apple Mail | Yes | Yes | Yes | Yes | Yes | Yes | -- Gmail | Yes | Yes | No | No | Yes | Only some parts | -- Outlook Live / 365 | Yes | Yes | Yes | No | Yes | No | -- Outlook 2013 | Yes | No | ? | -- | ? | ? | -- Outlook 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 New Outlook 2019 | Yes | No | Yes | -- | Yes | Yes | -- Yahoo Mail | Yes | Yes | No | Yes | Yes | Yes | The original information are all stuck to each other, without line breaks Thunderbird | Yes | Yes | No | Yes | Yes | Yes | -- Missive | Yes | Yes | No | No | Yes | No | -- HubSpot | Yes | Yes | Yes | Yes | Yes | Yes | -- IONOS by 1 & 1 | ? | Yes | ? | ? | Yes | ? | -- MailMate | Yes | Yes | ? | ? | Yes | ? | --

Contributing

Feel free to fork this project and submit fixes. We may adapt your code to fit the codebase.

You can run unit tests using:

npm test

License

email-forward-parser is released under the MIT License. See the bundled LICENSE file for details.