# eml-analyzer

> A tool to analyse the HTML version of an email message in `.eml` files.

Latest version **1.0.6** (published 2025-08-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install eml-analyzer
pnpm add eml-analyzer
yarn add eml-analyzer
bun add eml-analyzer
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2025-08-31 |
| First published | 2024-09-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=18.17 |
| Dependencies | 8 |
| Unpacked size | 22.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | husseinalhammad |
| Keywords | eml |

## Links

- npm: https://www.npmjs.com/package/eml-analyzer
- Repository: https://github.com/email-markup-consortium/eml-analyzer
- Homepage: https://github.com/email-markup-consortium/eml-analyzer#readme
- Issues: https://github.com/email-markup-consortium/eml-analyzer/issues
- npm.io page: https://npm.io/package/eml-analyzer

## Dependencies (8)

- [franc](https://npm.io/package/franc.md) ^6.2.0
- [cheerio](https://npm.io/package/cheerio.md) ^1.0.0-rc.12
- [postcss](https://npm.io/package/postcss.md) ^8.4.38
- [emoji-regex](https://npm.io/package/emoji-regex.md) ^10.3.0
- [tld-extract](https://npm.io/package/tld-extract.md) ^2.1.0
- [extract-urls](https://npm.io/package/extract-urls.md) ^1.4.1
- [letterparser](https://npm.io/package/letterparser.md) ^0.1.5
- [url-file-size](https://npm.io/package/url-file-size.md) ^1.0.5-1

## Recent versions

- 1.0.6 (latest) — 2025-08-31
- 1.0.5 — 2025-03-27
- 1.0.4 — 2025-03-27
- 1.0.3 — 2025-03-26
- 1.0.2 — 2024-09-29
- 1.0.1 — 2024-09-26
- 1.0.0 — 2024-09-26

## README

# eml-analyzer

A tool to analyse the HTML version of an email message in `.eml` files.


## Install

```
npm i eml-analyzer
```


## Usage

```js
import * as fs from "fs";
import emlAnalyzer from "eml-analyzer";

let analyzer = new emlAnalyzer("path/to/file.eml");

analyzer.run().then(() => {
  let result = analyzer.result;

  // print result to console
  console.log(result);

  // or save as JSON
  fs.writeFileSync(`results.json`, JSON.stringify(result, null, 2));
});
```


## Options

| Option                  | Type    | Default | Description                                     |
| ----------------------- | ------- | ------- | ----------------------------------------------- |
| fetchExternalAssetsSize | Boolean | false   | Whether to get the file size of external assets |


```js
let analyzer = new emlAnalyzer("path/to/file.eml", {
  fetchExternalAssetsSize: false,
});
```

## Results

The returned results include:

- Size (in bytes)
  - of the .eml file
  - of each MIME type
- MIME Types
- Subject line
  - Character count
  - Word count
  - Used emojis
- Sender
  - The TLD of sender domain
  - Subdomain
- Whether the email has attachements
- Language of email message
- HTML
  - Tags
  - Tag attributes
  - MSO conditional comments
  - URL protocols used in links
  - Structured data
    - Whether structured data is used (e.g. Gmail annotations)
    - Whether Microsoft Actionable Messages are used
- CSS
  - Whether invalid CSS is detected
  - CSS properties
  - CSS values
  - CSS selectors
  - CSS rules
  - CSS at-rules
- External assets
  - Image count
  - File formats
  - Optional: file sizes of external assets (in bytes)


```json
{
  "size": {
    "eml": 111062,
    "text": 4059,
    "html": 96074,
    "amp": 0
  },
  "mimeTypes": {
    "text": true,
    "html": true,
    "amp": false
  },
  "subject": {
    "chars": 25,
    "words": 4,
    "emojis": [
      "❤️‍🔥"
    ]
  },
  "sender": {
    "tld": "com",
    "subdomain": "",
    "government": false,
    "education": false
  },
  "hasAttachments": false,
  "language": {
    "code": "arb",
    "name": "Standard Arabic"
  },
  "html": {
    "urlProtocols": [
      "https:"
    ],
    "tags": {
      "meta": {
        "count": 5
      },
      "title": {
        "count": 1
      },
      "style": {
        "count": 1
      },
      "center": {
        "count": 1
      },
      "table": {
        "count": 5
      },
      "tbody": {
        "count": 5
      },
      "tr": {
        "count": 19
      },
      "td": {
        "count": 22
      },
      "div": {
        "count": 22
      },
      .
      .
      .
    },
    "attributes": [
      "charset",
      "http-equiv",
      "content",
      "name",
      "type",
      "align",
      "border",
      "cellpadding",
      "cellspacing",
      "height",
      "width",
      "id",
      "style",
      .
      .
      .
    ],
    "conditionalComments": [
      "[if gte mso 9]"
    ],
    "hasStructuredData": false,
    "hasMicrosoftActionableMessage": false
  },
  "css": {
    "hasInvalid": false,
    "properties": [
      "direction",
      "border-collapse",
      "mso-table-lspace",
      "mso-table-rspace",
      "-ms-text-size-adjust",
      "-webkit-text-size-adjust",
      "height",
      "margin",
      "padding",
      "width",
      .
      .
      .
    ],
    "values": [
      "rtl",
      "collapse",
      "0",
      "100%",
      "exactly",
      "9px",
      "separate",
      "0.5px solid #6E6E6E",
      "10px",
      "#FFF",
      "600px",
      "none no-repeat center/cover",
      .
      .
      .
    ],
    "selectors": [
      ":root",
      "img",
      "html",
      "body",
      ".gray-box",
      ".upper-footer",
      ".lower-footer",
      "body,#mainBody",
      "p,li,.main-content h5",
      .
      .
      .
    ],
    "rules": [
      {
        "property": "direction",
        "value": "rtl"
      },
      {
        "property": "border-collapse",
        "value": "collapse"
      },
      {
        "property": "mso-table-lspace",
        "value": "0"
      },
      {
        "property": "height",
        "value": "100%"
      },
      .
      .
      .
    ],
    "atRules": [
      {
        "name": "font-face",
        "params": ""
      },
      {
        "name": "media",
        "params": "(prefers-color-scheme: dark)"
      },
      {
        "name": "media",
        "params": "only screen and (max-width: 480px)"
      }
    ]
  },
  "externalAssets": {
    "imageCount": 15,
    "formats": [
      ".png",
      ".jpeg"
    ],
    "sizes": []
  }
}
```



## License

MIT Licensed, see License.md


## Credit

Parts of the code has been adopted form other EMC projects and were written by other developers not listed in this repository as contributors.

---
_Source: https://npm.io/package/eml-analyzer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
