emailify

Make HTML pages email-safe

This is the node.js version of premailer.

  • Copies <style />, and <link /> data to associated elements.
  • Strips out comments by default, but you can optionally keep them, this is useful if you intend to use VML to provide background-images.
  • HTML compatibility checking for popular email clients. See:
    • http://www.campaignmonitor.com/css/
    • http://www.campaignmonitor.com/downloads/documents-tools/campaign-monitor-guide-to-css-in-email-sept-2011.pdf
    • http://www.email-standards.org/

Turns this:

<html>
    <head>
        <style>
            h4 {
                color: #ff6600;
            }
        </style> 
    </head>
    <body>
        <h4>orange header</h4>
    </body>
</html>

Into this:

<html>
    <head>
    </head>
    <body>
        <h4 style="color: #ff6600;">orange header</h4>
    </body>
</html>

npm install emailify -g
-i [input_html] -o [output_html]
 
Options:
  -i, --input    [required]
  -o, --output  
  -t, --test     [default: false]
  -c, --comments [default: false]

To emailify a document, use this command:

emailify -i /my/html/file.html -o /my/html/emailified.html

If you intend to keep comments, do the following:

emailify -c true -i /my/html/file.html -o /my/html/emailified.html

You can easily test a document for compatibility by adding the -t flag:

emailify -i /my/html/file.html -o /my/html/emailified.html -t

Ommit -o if you just want to see what emailify produces:

emailify -i /my/html/file.html

parses html content into email-safe html

  • content - the html content
  • options
    • test - runs test against code for compatibility
var emailify = require('emailify'),
fs           = require('fs')
 
emailify.parse(fs.readFileSync('/my/email/newsletter.html', 'utf8'), function(errcontent) {
    //send newsletter 
});

loads a html file

var emailify = require('emailify'),
fs           = require('fs')
 
emailify.load('/my/email/newsletter.html', { test: true }, function(errcontentwarnings) {
    //send newsletter 
});