mirror of
https://gitlab.silvrtree.co.uk/martind2000/mqttArchiver.git
synced 2025-01-11 00:35:08 +00:00
45 lines
1.0 KiB
JavaScript
45 lines
1.0 KiB
JavaScript
/**
|
|
*
|
|
* User: Martin Donnelly
|
|
* Date: 2016-04-08
|
|
* Time: 16:35
|
|
*
|
|
*/
|
|
var UltraSES = require('ultrases'), dateFormat = require('dateformat');
|
|
|
|
var logger = require('log4js').getLogger();
|
|
|
|
var mailer = new UltraSES({
|
|
aws: {
|
|
accessKeyId: 'AKIAJWJS75F7WNCGK64A',
|
|
secretAccessKey: '8irYxThCp4xxyrbr00HzWcODe2qdNrR7X7S5BKup',
|
|
region: 'eu-west-1'
|
|
}, defaults: {
|
|
from: 'Martin Donnelly <martind2000@gmail.com>'
|
|
}
|
|
});
|
|
|
|
const prefix = process.env.NODE_ENV === 'production' ? 'Production' : 'Dev';
|
|
|
|
module.exports = {
|
|
|
|
sendEmailV1: function(contents) {
|
|
var now = new Date();
|
|
var email = {
|
|
to: 'martind2000@gmail.com', subject: 'MQTT ' + prefix + ' Archiver Alert'
|
|
};
|
|
|
|
var msg = '<h1>MQTT ' + prefix + ' Archiver Alert</h1><p>Alert logged at ' + dateFormat(now, "dddd, mmmm dS, yyyy, HH:MM:ss") + '</p><pre>' + contents + '</pre>';
|
|
|
|
mailer.sendHTML(email, msg, function(err){
|
|
if(err) {
|
|
logger.error(err);
|
|
throw err;
|
|
}
|
|
logger.info('email sent!');
|
|
});
|
|
|
|
|
|
}
|
|
};
|