Skip to content

Instantly share code, notes, and snippets.

@adkron
Created February 24, 2017 20:32
Show Gist options
  • Save adkron/d61b3a42f28c721ca5680497641d1ca1 to your computer and use it in GitHub Desktop.
Save adkron/d61b3a42f28c721ca5680497641d1ca1 to your computer and use it in GitHub Desktop.
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: 'hello@evmatch.co',
from_name: 'EVmatch',
to: [
{email: 'founders@evmatch.com', 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