Skip to content

Getting Started

Dan Sabin edited this page Jun 8, 2026 · 1 revision

Getting Started

Install

npm install inline-email

Inline Email v3 targets Node.js 20 and newer.

Compile Once

Compile templates at build time, deploy time, or application startup:

const { compileEmailTemplate } = require('inline-email');

const compiled = await compileEmailTemplate({
  subject: 'Welcome to ACME, {{firstName}}',
  html,
  css,
  text: 'Welcome to ACME, {{firstName}}'
});

Render Per Send

Render dynamic data when the email is sent:

const email = compiled.render({
  data: {
    firstName: 'Dan',
    appUrl: 'https://app.example.com'
  }
});

// email.subject
// email.html
// email.text

One-Shot Rendering

For simple workflows:

const { renderEmail } = require('inline-email');

const email = await renderEmail({
  template: {
    subject: 'Welcome, {{firstName}}',
    html: '<p>Hello {{firstName}}</p>'
  },
  data: {
    firstName: 'Dan'
  }
});

CLI

inline-email input.html
inline-email input.html --out output.html
inline-email --css style.css input.html

Supported options:

--html <file>          Input HTML file. A positional input file is also supported.
--css <files...>       CSS files to inline.
--out, -o <file>       Write output to a file instead of stdout.
--noInlineImages       Disable image web resource inlining.
--force, -f            Overwrite the output file.
--help, -h             Show help text.

Local Examples

npm run examples

Then open examples/out/index.html.

Clone this wiki locally