Moogsoft Docs

Mailer

The Mailer module allows you to send an email in response to events occurring in Moogsoft AIOps.

You can load it 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.

To load the Mailer module, define a new global object mailer at the top of the Moobot JavaScript file:

var mailer = MooBot.loadModule('Mailer');

Reference Guide

You can use the following methods with the Mailer Moobot module.

initTransport

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",
	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).

If you do not want Mailer to send authentication credentials to the SMTP mail server, do not define the password property:

mailer.initTransport({server: "yourhostname", port: 25, account:"username@emailhost.com" });

If the password property is omitted, an unauthenticated connection is created between the Mailer Moobot and the server.

send

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 Argument

Name

Type

Description

mailMsg 

Object

A JSON object containing fields needed to populate the email.

Example

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
	};
mailer.send(mailMsg);