caniemail
Version:
HTML and CSS Feature Support for Email Clients from caniemail.com
171 lines (122 loc) • 3.24 kB
Markdown
[](https://liberamanifesto.com)
Check HTML and CSS Feature Support for Email Clients from [caniemail.com](https://caniemail.com)
The packages requires an [LTS](https://github.com/nodejs/Release) Node version (v20.19.0+)
Install the package from npm using your favourite package manager:
```shell
pnpm add caniemail
```
Returns:
```typescript
interface CanIEmailResult {
issues: FeatureIssues;
success: boolean;
}
```
Type: `CanIEmailOptions`
```typescript
interface CanIEmailOptions {
/**
An array of client names or globs to match email clients.
Example: ['gmail.android', 'outlook.*', '*.ios']
*/
clients: EmailClientGlobs[];
css?: string;
html?: string;
}
```
Type: `EmailClientGlobs[]`<br>
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](https://www.npmjs.com/package/micromatch) documentation.
To match all clients, pass `['*']`.
Possible email clients:
```javascript
[
'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"]`
Type: `string`<br>
Required: `false`
CSS string to analyze for email client compatibility.
Type: `string`<br>
Required: `false`
HTML string to analyze for email client compatibility.
> [!NOTE]
> At least one of `css` or `html` must be provided.
Returns:
```typescript
{
message: string;
notes: string[];
}
```
Type:
```typescript
interface FormatIssueOptions {
client: EmailClient;
issue: FeatureIssue;
issueType: 'error' | 'warning';
}
```
Type: `EmailClient`<br>
Required: `true`
The email client to format the issue for.
Type: `FeatureIssue`<br>
Required: `true`
The feature issue to format.
Type: `'error' | 'warning'`<br>
Required: `true`
The type of issue being formatted. Determines the formatting of the message.
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](./CONTRIBUTING.md).
[](./LICENSE.md)