Skip to content

scandox/nodemailer-juice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nodemailer Plugin for inlining CSS using Juice

This plugin uses juice to inline CSS styles present in the html value of the nodemailer mail object.

At present the plugin uses the juiceResources method which does fetch remote resources present in the html.

Install

Install from npm

npm install nodemailer-juice --save

Usage

Load the plugin

var inlineCss = require('nodemailer-juice');

Attach it as a 'compile' handler for a nodemailer transport object, with options

nodemailerTransport.use('compile', inLineCss(options))

Where

  • options - includes options for juice

Example

var nodemailer = require('nodemailer');
var inLineCss = require('nodemailer-juice');
var transporter = nodemailer.createTransport();
transporter.use('compile', inLineCss());
transporter.sendMail({
    from: '[email protected]',
    to: '[email protected]',
    html: '<style>div { color:red; }</style><div>Hello world!</div>'
});

Will result in an email with the following HTML:

<div style="color: red;">Hello world!</div>

License

MIT

About

A Nodemailer Plugin for inlining CSS using Juice

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published