2.0.0 • Published 5 years ago

mailshine v2.0.0

Weekly downloads
35
License
MIT
Repository
github
Last release
5 years ago

mailshine

A simple and lightweight library that cleans html email content for use in other environments.

Email clients will often populate emails with style and class tags in the HTML they send. In addition, email clients will quote the entire previous email chain with each reply. While all these techniques work for traditional email, they cause headaches for email integration into other apps.

This library solves this problem.

Overview

Mailshine uses regex patterns to detect the beginning of the quoted part of an email. All content at and after that point is removed.

There is no common format for quoted email replies. Email clients often devise their own way of indicated quoted content. Mailshine includes regex patterns that capture the email replies of the following email clients:

  • Apple iPhone
  • Gmail
  • Apple iPad
  • Google Android
  • Apple Mail Web client
  • Outlook
  • Yahoo
  • Outlook web client
  • Thunderbird

This list covers more than 90% of email clients in use. It may be safe to assume that the coverage is a few % higher because less used clients likely use some of the same patterns to indicate email replies. Source

If you find an email client that uses a reply format that is not picked up by the included regex patterns, you can add your own custom regex patterns. In addition, if you find that one of the current patterns is incorrectly parsing or causing unwanted side effects, you can remove specific regex patterns if wanted. For usage, view the Usage section below.

If their is broader applications to the addition or subtraction of a regex pattern, please open an issue.

Setup

At the moment Mailshine is only available on Node. A browser compatible version is coming soon.

Install via console: npm install mailshine

Usage

const Mailshine = require('mailshine');

const adds = [/reply:/g];
const removes = [/\\>.*?[\s]\>/g];

html = "<p>Hi Warren! Tennis this weekend?</p><div>To: mikejonesab12@gmail, From: Warren Buffet</div><p>Hey, it's your pal Warren :)</p>";


let output = Mailshine(html); // without any custom adds or removes.
output = Mailshine(html, {adds, removes}); // without any custom adds or removes.

//Output:
{
    htmlContent: "<p>Hi Warren! Tennis this weekend?</p>",
    htmlQuote: "<div>To: mikejonesab12@gmail, From: Warren Buffet</div><p>Hey, it's your pal Warren :)</p>",
    markdownContent: "Hi Warren! Tennis this weekend?",
    markdownContent: "To: mikejonesab12@gmail, From: Warren Buffet\n\nHey, it's your pal Warren :)"
}

Todo

  • Add tests
2.0.0

5 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago