A nodemailer plugin for inlining CSS using Juice
npm install nodemailer-juiceThis 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 from npm
npm install nodemailer-juice --save
Load the plugin
``javascript`
var inlineCss = require('nodemailer-juice');
Attach it as a 'compile' handler for a nodemailer transport object, with options
`javascript`
nodemailerTransport.use('compile', inLineCss(options))
Where
* options - includes options for juice
`javascript``
var nodemailer = require('nodemailer');
var inLineCss = require('nodemailer-juice');
var transporter = nodemailer.createTransport();
transporter.use('compile', inLineCss());
transporter.sendMail({
from: 'me@example.com',
to: 'receiver@example.com',
html: 'Hello world!'
});
Will result in an email with the following HTML:
MIT