@jsx-email/doiuse-email
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

libera manifesto

@jsx-email/doiuse-email

This package is a part of the jsx-email suite of tools.

@jsx-email/doiuse-email is a tool for checking the HTML and CSS support of various email clients based on Can I email.

Inspired by the excellent doiuse library.

Installation

Install the package from npm using your favourite package manager:

npm install @jsx-email/doiuse-email

Programmatic Usage

Import it and run it by calling doIUseEmail(html: string, options: DoIUseOptions):

import { doIUseEmail } from '@jsx-email/doiuse-email';

const result = doIUseEmail(
  `
  <!doctype html>
  <html>
    <body>
      <div style='background-color: orange'></div>
    </body>
  </html>
  `,
  { emailClients: ['gmail.*'] }
);

console.log(result);
/*
  {
    "notes": [
      "Note about `<body> element` support for `gmail.desktop-webmail`: Partial. Replaced by a `<div>` with supported attributes.",
      "Note about `<body> element` support for `gmail.ios`: Partial. Replaced by a `<div>` with supported attributes.",
      "Note about `<body> element` support for `gmail.android`: Partial. Replaced by a `<div>` with supported attributes.",
      "Note about `<body> element` support for `gmail.mobile-webmail`: Partial. Replaced by a `<div>` with supported attributes.",
    ],
    "success": true,
  }
*/

// Output is based on https://caniemail.com

API

doIUseEmail(html, options)

html

Type: string

The HTML that represents the email.

options

emailClients

Type: string[]

An array of globs for matching email clients to be checked against the Can I Email database. For more information about the glob syntax that is used, refer to the micromatch package.

Possible email clients:

[
  'apple-mail.macos',
  'apple-mail.ios',
  'gmail.desktop-webmail',
  'gmail.ios',
  'gmail.android',
  'gmail.mobile-webmail',
  'orange.desktop-webmail',
  'orange.ios',
  'orange.android',
  'outlook.windows',
  'outlook.windows-mail',
  'outlook.macos',
  'outlook.ios',
  'outlook.android',
  'yahoo.desktop-webmail',
  'yahoo.ios',
  'yahoo.android',
  'aol.desktop-webmail',
  'aol.ios',
  'aol.android',
  'samsung-email.android',
  'sfr.desktop-webmail',
  'sfr.ios',
  'sfr.android',
  'thunderbird.macos',
  'protonmail.desktop-webmail',
  'protonmail.ios',
  'protonmail.android',
  'hey.desktop-webmail',
  'mail-ru.desktop-webmail',
  'fastmail.desktop-webmail',
  'laposte.desktop-webmail'
];

Example: ["gmail.*", "*.desktop-webmail"]

Package Sidebar

Install

npm i @jsx-email/doiuse-email

Weekly Downloads

17,380

Version

1.0.4

License

MIT

Unpacked Size

5.22 MB

Total Files

9

Last publish

Collaborators

  • shellscape