Created
February 24, 2017 20:32
-
-
Save adkron/d61b3a42f28c721ca5680497641d1ca1 to your computer and use it in GitHub Desktop.
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
const config = require('../../config.json') | |
const mandrill_api_key = config[process.env.NODE_ENV].mandrill_api_key | |
const mandrill = require('mandrill-api/mandrill') | |
const mandrill_client = new mandrill.Mandrill(mandrill_api_key) | |
const defaultEmailProperties = { | |
from_email: '[email protected]', | |
from_name: 'EVmatch', | |
to: [ | |
{email: '[email protected]', name: 'Founders'}, | |
], | |
tags: [''], | |
} | |
module.exports = { | |
sendVehicleChargeRequest: function(vehicleChargeRequest) { | |
email = Object.assign({}, defaultEmailProperties, { | |
subject: 'Charging Request', | |
text: ` | |
start time: ${vehicleChargeRequest.start_time} | |
end time: ${vehicleChargeRequest.end_time} | |
user ID: ${vehicleChargeRequest.requester_id} | |
host ID: ${vehicleChargeRequest.host_id} | |
user email: Coming soon | |
host email: Coming soon | |
`, | |
}) | |
mandrill_client.messages.send({ | |
message: message, | |
async: true, | |
}, | |
function(result) { | |
console.log(result) | |
}, | |
function(error) { | |
console.log('A mandrill error occurred: ' + error.name + ' - ' + error.message) | |
}, | |
); | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment