Registry / productivity / mailjs

mailjs

JSON →
library0.1.18jsnpmunverified

Mail.js is an open-source JavaScript library for rendering HTML and text emails. Version 0.1.18 is current, with infrequent releases. It focuses on email rendering via CSS inlining and HTML-to-text conversion, differentiating itself as a lightweight browser/Node solution for email generation without heavy dependencies. Supports ESM and CJS.

npm install mailjs
INSTALL
IMPORT
SIG · MAILJS
M
mailjs
productivityjavascriptv0.1.18
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import Mail from 'mailjs'
const Mail = require('mailjs')
ESM import provides default export.
TextRendrer
import { TextRendrer } from 'mailjs'
Named export for text rendering.
Mail (type)
import type { Mail } from 'mailjs'
Type import for TypeScript.

Creates a Mail instance, renders HTML with CSS inlining, and outputs formatted HTML and plain text.

import Mail from 'mailjs'; const mail = new Mail(); const html = '<h1>Hello</h1>'; const options = { css: 'h1 { color: red; }' }; mail.render(html, options).then(result => { console.log(result.html); console.log(result.text); }).catch(err => console.error(err));
Debug
Known issues
gotcharender() returns a promise; must be awaited or handled with .then()
fix
Use await or .then() when calling render.
affects: >=0.1.0
deprecatedPromise-based API replaced callbacks in v0.1.0
fix
Use async/await instead of callback parameters.
affects: >=0.1.0
gotchaCSS inlining may not work with complex selectors or media queries
fix
Preprocess CSS to inline styles manually for robust email rendering.
affects: >=0.1.0
Errors
Common errors & fixes
Mail is not a constructor
Using require() in ESM context or missing default import
fix
Use 'import Mail from 'mailjs'' instead of require.
mail.render is not a function
Instantiating without new keyword
fix
Use 'new Mail()' to create an instance.
Cannot find module 'mailjs'
Package not installed or import path incorrect
fix
Run 'npm install mailjs' and ensure import path is correct.
Upgrade
Version history
0.1.18latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
34 hits · last 30 days
node
30
Amazon
1
OpenAI (training)
1
Resources
packagemailjs
mailjs — npm install mailjs · libregistry