Skip to content

Instantly share code, notes, and snippets.

@eibrahim
Created July 22, 2016 13:05
Show Gist options
  • Save eibrahim/ee407e01963097e5d1b6250a3285498e to your computer and use it in GitHub Desktop.
Save eibrahim/ee407e01963097e5d1b6250a3285498e to your computer and use it in GitHub Desktop.
A node worker for firebase to send emails using mandrill
var mandrill = require('mandrill-api/mandrill');
var mandrill_client = new mandrill.Mandrill('YOUR MANDARILL KEY');
var FROM_EMAIL = 'info@ourstandup.com';
var FROM_NAME = 'Our Standup';
var db = require('./database');
var invitationsRef = db.ref("invitations");
var teamsRef = db.ref("teams");
var usersRef = db.ref("users");
var manager = {
send: function(to, name, subject, body){
var message = {
"html": "<p>"+ body + "</p>",
"subject": subject,
"from_email": FROM_EMAIL,
"from_name": FROM_NAME,
"to": [{
"email": to,
"name": name || to,
"type": "to"
}],
"headers": {
"Reply-To": "noreply@ourstandup.com"
},
"auto_text": true,
"merge": true,
"merge_language": "handlebars",
"metadata": {
"website": "www.ourstandup.com"
},
};
var async = true;
mandrill_client.messages.send({"message": message, "async": async }, function(result) {
}, function(e) {
console.log('A mandrill error occurred: ' + e.name + ' - ' + e.message);
});
}
}
module.exports = manager;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment