# premailer-api

> Node wrapper for the Premailer API (premailer.dialect.ca/api)

Latest version **1.0.4** (published 2016-04-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install premailer-api
pnpm add premailer-api
yarn add premailer-api
bun add premailer-api
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2016-04-25 |
| First published | 2012-10-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >0.8.* |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 75 |
| Author | Jed Watson |
| Maintainers | jedwatson |
| Keywords | premailer, css, email, api, inliner, newsletter |

## Links

- npm: https://www.npmjs.com/package/premailer-api
- Repository: https://github.com/JedWatson/node-premailer
- Issues: https://github.com/JedWatson/node-premailer/issues
- npm.io page: https://npm.io/package/premailer-api

## Dependencies (2)

- [request](https://npm.io/package/request.md) ^2.72.0
- [underscore](https://npm.io/package/underscore.md) ^1.8.3

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2016-04-25
- 1.0.3 — 2014-06-27
- 1.0.2 — 2013-09-23
- 1.0.1 — 2012-10-23
- 1.0.0 — 2012-10-22

## README

node-premailer
==============

A simple api wrapper for http://premailer.dialect.ca, a great tool for inlining css before you send an email.

node-premailer simplifies api integration by calling the Premailer API to inline css styles (and other options such as removing comments, classes and ids), then retrieving the generated html and text from their respective URLs before passing them to your callback.


## Install

<pre>
  npm install premailer-api
</pre>

Or from source:

<pre>
  git clone git://github.com/JedWatson/node-premailer.git
  cd node-premailer
  npm link
</pre>

## Usage

```javascript
var premailer = require('premailer-api');

var emailTemplate = '
  <html>
    <head>
      <title>My Email</title>
      <style type="text/css">
        a { color: #336699; }
      </style>
    </head>
    <body>
      Styles inlined with
      <a href="http://premailer.dialect.ca">Premailer</a> via
      <a href="https://github.com/JedWatson/node-premailer">node-premailer</a>.
    </body>
  <html>';

premailer.prepare({html: emailTemplate }, function(err, email) {
  res.send(email.html);
});
```

## Options

- premailerAPI (string)
  The URL of the premailer API. If you're running your own, replace this. Defaults to http://premailer.dialect.ca/api/0.1/documents
- html (string)
  The html of the email to parse and inline styles.
- url (string)
  The url of the email to fetch then parse and inline styles.
- fetchHTML (boolean)
  Whether to fetch the parsed HTML (you'll usually want this). Defaults to true.
- fetchText (boolean)
  Whether to fetch the auto-generated text version (disable this if you are providing your own). Defaults to true.
- See http://premailer.dialect.ca/api for full list of options. All options have aliases for node.js style variable names.
  - `adapter`
  - `baseUrl` || `base_url`
  - `lineLength` || `line_length`
  - `linkQueryString` || `link_query_string`
  - `preserveStyles` || `preserve_styles`
  - `removeIds` || `remove_ids`
  - `removeClasses` || `remove_classes`
  - `removeComments` || `remove_comments`


## License and Credits

MIT Licensed. Copyright Jed Watson 2016.

A big thank you to [Dialect](http://dialect.ca) for Premailer, and for making the API freely available.

There's also a web version available here: http://premailer.dialect.ca

And you can check out the source code for Premailer itself here: https://github.com/alexdunae/premailer/

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