Détail du package

caniemail

avigoldman3.2kMIT1.0.0

HTML and CSS Feature Support for Email Clients from caniemail.com

caniemail, caniuse, check, client

readme

libera manifesto

caniemail

Check HTML and CSS Feature Support for Email Clients from caniemail.com

Requirements

The packages requires an LTS Node version (v20.19.0+)

Installation

Install the package from npm using your favourite package manager:

pnpm add caniemail
# bun add caniemail
# yarn add caniemail
# npm add caniemail

Exports

caniemail(html, options)

Returns:

interface CanIEmailResult {
  issues: FeatureIssues;
  success: boolean;
}

options

Type: CanIEmailOptions

interface CanIEmailOptions {
  /**
    An array of client names or globs to match email clients.
    Example: ['gmail.android', 'outlook.*', '*.ios']
  */
  clients: EmailClientGlobs[];
  css?: string;
  html?: string;
}
clients

Type: EmailClientGlobs[]
Required: true

An array of globs for matching email clients to be checked against CanIEmail data. For more information about the glob syntax that is used, refer to the micromatch documentation.

To match all clients, pass ['*'].

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"]

css

Type: string
Required: false

CSS string to analyze for email client compatibility.

html

Type: string
Required: false

HTML string to analyze for email client compatibility.

Note: At least one of css or html must be provided.

formatIssue(options)

Returns:

{
  message: string;
  notes: string[];
}

options

Type:

interface FormatIssueOptions {
  client: EmailClient;
  issue: FeatureIssue;
  issueType: 'error' | 'warning';
}
client

Type: EmailClient
Required: true

The email client to format the issue for.

issue

Type: FeatureIssue
Required: true

The feature issue to format.

issueType

Type: 'error' | 'warning'
Required: true

The type of issue being formatted. Determines the formatting of the message.

Contributing, Working With This Repo

We 💛 contributions! After all, this is a community-driven project. We have no corporate sponsorship or backing. The maintainers and users keep this project going!

Please check out our Contribution Guide.

License

MIT License