Skip to content

Instantly share code, notes, and snippets.

@jondcallahan
Created February 4, 2016 22:24
Show Gist options
  • Save jondcallahan/2419f8c3f35766da32de to your computer and use it in GitHub Desktop.
Save jondcallahan/2419f8c3f35766da32de to your computer and use it in GitHub Desktop.
Send an html email from the command line via Mandrill. Useful for rapidly testing html emails.
var email = require('mandrill-send')('MANDRILL_API_KEY');
var fs = require('fs');
require.extensions['.html'] = function (module, filename) {
module.exports = fs.readFileSync(filename, 'utf8');
};
var htmlEmail = require("PATH_TO_FILE.HTML");
email({
from: 'FROM_NAME <[email protected]>',
to: [{ name: 'TO_NAME', email: '[email protected]' }],
subject: Date(),
html: htmlEmail
}, function(err){
if (err) console.error(err);
console.log('Sent!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment