Sending email messages with SENDMAIL.BAT
It might be that certain events are so critical that an operator wants to be notified of the event via e-mail or a pager. The SENDMAIL.bat action program can accomplish this. When configured as an action, the program will connect to an SMTP server, and send an e-mail message to a single configured user. The default message is suitable for use with an alphanumeric pager, or for collection by a mail program. To send to multiple users, the administrator can configure additional instances of the SENDMAIL.bat program, or can modify the batch file to include CC or BCC directives.
The SENDMAIL.bat program requires three arguments: The first argument is the hostname or IP address of an SMTP server, the second argument is the e-mail address of the person sending the e-mail message, and the third argument is the recipient of the e-mail message.
The content of the e-mail message, by default, consists of a subject (that indicates the severity) followed by the body of the message (that indicates the time, the hostname, the facility, and the message). This is configurable in the SENDMAIL.bat program. An administrator can modify the content of the message, including the Subject line.
In particular, an administrator can copy the SENDMAIL.bat program to the SENDPAGE.bat file, hardcode the SMTP server or e-mail address, and possibly omit the subject line to make the message appear better on a text pager. The SENDMAIL.bat program is well commented, and designed for easy adaptation.
The SENDMAIL.bat program makes use of the BMC Defender Server/system/sendmail.exe program, that is a useful command line utility for sending e-mail messages, and that has brief help built into the program. This sendmail.exe program takes four arguments: the destination host, a from e-mail address a to e-mail address, and the pathname to a file that contains the message to send. Within the file that is sent, the standard e-mail headers of Subject: CC:, BCC: and other items can be placed prior to composing the message.
Given that, the operation of the SENDMAIL.bat program is easily understood. SENDMAIL.bat simply constructs a temporary file, executes the sendmail.exe program, and then deletes the temporary file. (Because the CO-Catlog.exe program processes each event sequentially, there is no possibility of one device conflicting with another device, and the temporary filename does not have to be unique.)
The typical reasons for e-mail messages failing to be sent are as follows:
- The From e-mail address may need to be set to the name of a valid user on the system. Some SMTP servers will deny access to the system unless both the hostname is known, and the From address indicates a valid user of the system. In that case, the administrator should make sure that the second argument to the SENDMAIL.bat program is a valid e-mail user.
- A virus protection program may be blocking the transmission of e-mail messages. All virus protection programs have an Exclude setting that permits you to enter the sendmail.exe program as a valid program for sending e-mail on the system. Either disable the virus protection program, or add the sendmail.exe program as exclusion to the virus checker.
- The destination user is not reachable, or is invalid, or the SMTP server is not valid. This is a surprisingly common problem that is easily fixed by verifying the correct SMTP server name, the from e-mail address, and to e-mail address are specified as the three arguments to the SENDMAIL.bat program.
One easy way to test communication to the SMTP server is to use telnet at a command line prompt, and connect to port 25 of the SMTP server. For instance, you can issue the command telnet smtp-server 25 and see if the telnet session can be started. This simple technique can be used to troubleshoot a large measure of problems.
Another way to test the program: You can interactively execute the BMC Defender Server/system/sendmail.exe program at a command prompt, and see what error messages (if any) result. These error messages will also appear in the actions/sendmail.log program whenever the SENDMAIL.bat action program is executed.
Related topic