silvrgit/lib/today/mailer.js

38 lines
918 B
JavaScript
Raw Normal View History

/**
*
* User: Martin Donnelly
* Date: 2016-04-08
* Time: 16:35
*
*/
var jade = require('jade'), UltraSES = require('ultrases'), dateFormat = require('dateformat');
var logger = require('log4js').getLogger();
var mailer = new UltraSES({
aws: {
accessKeyId: 'AKIAJWJS75F7WNCGK64A',
secretAccessKey: '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',
region: 'eu-west-1'
}, defaults: {
from: 'Martin Donnelly <martind2000@gmail.com>'
}
});
module.exports = {
sendEmailV1: function(todayCache, newpath) {
var now = new Date();
var email = {
to: 'martind2000@gmail.com', subject: 'Today - ' + dateFormat(now, 'dddd, mmmm dS, yyyy')
};
var template = {
file: newpath + '/' + 'jade/today.jade', locals: todayCache
};
mailer.sendTemplate(email, template, function(err) {
if (err) throw err;
logger.info('compiled template email sent');
});
}
};