Note: Example Four extends the alert policy in Example Three. Example Four provides information about sending alert emails using .Net application instead of Visual Basic script. The code for the mail alert will be provided along with the installer for any further customization. There will not be any support provided for any modifications done to the provided code.
You can send email messages from the local or remote SMTP servers through the .Net application Mail_Alert.exe. This .Net application is provided in the alarm_scripts folder under the Data folder. The .Net application is configured through the Mail_Alert.exe.config file. The Mail_Alert.exe.config file contains the key-value pairs in the form of <add key="" value=""/> statements under the <appSettings> tag.
Notes:
Edit the the Mail_Alert.exe.config file by using only Notepad or Notepad++ text editor. Usage of other text editors can result in erroneous output.
Distribution Lists can be specified as values for the To Recipient and CC Recipient fields in the Mail_Alert.exe.config file and in the Command field of the details pane.
Error codes are written in the Application Event Log if there is no valid email ID provided in the To Recipient value or if the Mail_Alert.exe.config file is not configured accurately.
To implement this change
In the Mail_Alert.exe.config file, provide the value of the SMTPSERVER as a DNS name or IP address of the SMTP server.
The value of the SMTPSERVER can either be "localhost" in case of using a local SMTP server or it can be the remote SMTP server’s name/IP address if a remote SMTP server is used to send the email messages. The default value is "localhost".
In the Mail_Alert.exe.config file, provide the value of the SMTPSERVERPORT, that is, the port number on which the SMTP server receives connections. The default value is 25.
In the Mail_Alert.exe.config file, provide the value of the To Recipient, that is, one or more valid email IDs separated by commas. You can also provide the value of the To Recipient after the command value in the Command field of the details pane. For example, if the To Recipient comprises of jdoe@any.com and bgood@another.com, then provide the following consolidated value for the Command field:
cmd.exe /C Mail_Alert.exe jdoe@any.com,bgood@another.com
The alert message is sent to the email IDs provided as the value of the To Recipient.
In the Mail_Alert.exe.config file, provide the value of the CC Recipient, that is, one or more valid email IDs separated by commas. You can also provide the value of the CC Recipient after the To Recipient value in the Command field of the details pane. For example, if the To Recipient comprises of jdoe@any.com and bgood@another.com and the CC Recipient comprises of a@b.com and c@d.com, then provide the following consolidated value for the Command field:
cmd.exe /C Mail_Alert.exe jdoe@any.com,bgood@another.com a@b.com,c@d.com
Note: In the Command field, a single space is used to separate the Command field value from the To Recipient value, and another single space is used to separate the To Recipient value from the CC Recipient value
A copy of the alert message is sent to the email IDs provided as the value of the CC Recipient.
In the Mail_Alert.exe.config file, provide the value of the From_Address, that is, one valid email ID. For example x@y.com.
Note: If you do not provide any value in the From_Address field, the default value of username@computername is used; where username is the user name of the user currently logged onto the system and computername is the name of the server originating the mails.
In the Mail_Alert.exe.config file, provide the value of the Instance_Name, Severity, and Alert_ID as yes, if you wish to view all the three parameters in the subject line of the mail alert. If you want to customize the subject line, that is, disable a particular parameter, remove the value yes against the respective parameter. For example, <add key="Instance_Name" value=""/>. This enables you to view the parameters of your choice in the subject line.
Save the Mail_Alert.exe.config file with read and execute permission.
In the navigation pane, under the Alert Policies node, select the alert policy you created in Example One.
Add a command template to this alert policy.
Specify the command in the Command field in the details pane as cmd.exe /C Mail_Alert.exe.
Add an action to the action list you created in Example One that refers to the new command template, and in the new action, select Raise as the Action Event property value.
Save the updated alert policy.
Reactivate the updated alert policy.
The following SMTP failure cases are handled:
Failure Cases (Error Codes) | Description |
---|---|
MAILBOXUNAVAILABLE (550) | The destination mailbox was not found or could not be accessed. |
MAILBOXBUSY (450) | The destination mailbox is in use. |
SERVICECLOSINGTRANSMISSIONCHANNEL (-1) | The SMTP service is closing the transmission channel. |
SERVICENOTAVAILABLE (221) | The SMTP service is not available, the server is closing the transmission channel. |
GENERALFAILURE (421) | The transaction could not occur. You will receive this error when the specified SMTP host cannot be found. |
Note: In case of SMTP failures, retry option is provided three times with a delay of 10 seconds.
The Mail_Alert.exe.config file is configured and alert emails are sent to the email IDs mentioned in the To Recipient and CC Recipient value fields.
Ensure the following when you configure the Mail_Alert.exe.config file:
The Mail_Alert.exe.config file and the .Net application to send the email messages should be in the alarm_scripts folder under the Data folder.
Do not provide any value for ClientSettingsProvider.ServiceUri in the Mail_Alert.exe.config file.
Provide all the values in the Mail_Alert.exe.config file within double quotes.
The Operations Sentinel server must have the local SMTP service enabled and configured to forward mails to a mail host or the Mail_Alert.exe.config file must be modified to use the remote SMTP server. The application relies on the following environment variables that are made available to Operations Sentinel Alert actions:
SP_ALERTID
SP_INSTANCE
SP_SEV
SP_TEXT