-
-
Save eusthace811/a4d45b9c8f3cc1bb96d0127f4cea7cab to your computer and use it in GitHub Desktop.
A node worker for firebase to send emails using mandrill
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var mandrill = require('mandrill-api/mandrill'); | |
| var mandrill_client = new mandrill.Mandrill('YOUR MANDARILL KEY'); | |
| var FROM_EMAIL = '[email protected]'; | |
| 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": "[email protected]" | |
| }, | |
| "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