A node-alert plugin to mail configured users on errors/events
var mailAlert = require('node-alert')({
plugins : {
mail : {
nodemailer : { // Any valid nodemailer option set can be used
port : 25,
host : "smtp.myserver.com",
auth : {
user : "[email protected]",
pass : "mypass"
},
message : {
sender : "[email protected]",
receiver : "[email protected]",
addressed_to : "node-alert maintainer",
serviceName : "Node-Alert test",
instance : "inst001",
origin : "node-server",
link : "http://example.com/dashboard/instance/health",
link_text : "Instance Health",
}
}
}
});
mailAlert.alertMail(new Error('Test Error'), function(err, info) {
if (err) console.log(err);
else console.log('Success!');
});nodemailer
Nodemailer is internally used to send mails. Any format acceptable by Nodemailer'screateTransportmethod, can be usedmessage
This sub option contains details relevant to creating the message body of the mail that will be sent on an eventsender
The address that will be present in thefromheader of the mail
Note: Sending mails from unauthorized addresses will be regarded as spam in most email servicesreceiver
The address that will be present in thetoheader of the mailaddressed_to
The person/group/organization the mail addressesserviceName
The name of the service. (Useful in case you are running many)instance
The unique identifier for this instance. (Useful in case you are running many)origin
The name of the component whose malfunction causes this alertlink
A quick link that takes you to a health check url. (This URL should be behind a VPN or should have an authentication mechanism)link_text
Text forlink. Iflinkis provided andlink_textis not,linkitself will be used aslink_text
In the above example, all options under message are optional. However they will help you drill down on the error and take quick actions on receiving a crash report.
If sender/receiver options are skipped, the plugin will try to use auth.user in the nodemailer option as the sender/receiver.