Mailer
The Mailer module allows you to send an email in response to events occurring in AIOps.
It can be used load into any standard MooBot. For example, you can load Mailer into Notifier.js MooBot and send users emails if they are invited to a Situation Room.
Configure Mailer
To load the Mailer module, define a new global object mailer at the top of the MooBot JavaScript file:
var mailer = MooBot.loadModule('Mailer');
You can configure Mailer using the methods listed in the sections below.
Methods
mailer.initTransport(mailerObj)
Defines the mail server information needed to send the email in the send function.
Request Argument
Name |
Type |
Description |
---|---|---|
mailerObj |
Object |
A JSON object specifying connection properties |
Example
mailer.initTransport({ server: "smtp.mailserver.com", port: 2525, account: "user@mailserver.com", password: "m00gsoft", // Set to true, to decrypt the above password value. // Use the moog_encryptor utility to encrypt a password or secret value. isEncrypted: false, start_tls: false, use_tls: false });
In general, use the guidelines below for the following ports:
- If using port 587, set start_tls to true and use_tls to false
- If using port 465, set start_tls to true and use_tls to true
- If using port 25, set start_tls to false and use_tls to false (or comment both flags out)
Note
Please note
: If you do not want Mailer to send authentication credentials to the SMTP mail server, do not specify the
'password'
field:
mailer.initTransport({server: "yourhostname", port: 25, account:"username@emailhost.com" });
If '
password
' is omitted, an unauthenticated connection is created between Mailer and the server.
mailer.send(mailMsg)
Use this method to send email. A callback function needs to be defined in the same Moobot and referenced in the mailMsg which is executed after a successful transmission.
Request Arguments
Name |
Type |
Description |
---|---|---|
mailMsg |
Object |
A JSON object containing fields needed to populate the email |
Example
// // Ok, we must now construct a message to be sent by the mailer // var mailMsg={ to : "destination@mail.com", subject : "MOOGsoft Situation Room Notification", message : "email body", invite : invite, // do not change bot : MooBot.self, // do not change callback: "sendSuccess", // the name of the function to run in this Moobot args : [invite_id,"Sent successfully",vector] // do not change }; // // Send it // mailer.send(mailMsg);