Note: This article describes an unsupported utility.
Introduction
There are lots of reasons why your mail may stop working, hardware, network failures, disk corruption etc. and there are lots of utilities available designed to monitor various aspects of your network and report accordingly. However good these utilities are, they cannot prove that mail is leaving your system sucessfully.
In contrast, the MailMonitor utility provided here does not monitor any individual aspect of your network, but monitors the (more important) overall ability of the system to send out emails.
How the utility works
On the Mailtraq server being monitored, a 'trace' email is generated every five minutes. This is injected into Mailtraq's pending folder, and routed like any other email.
The trace emails need to be addressed to a specially setup mailbox running elsewhere on a separate copy of Mailtraq.
A script included in this kit monitors that mailbox, and if no email is received within a fifteen minute timespan, raises an alert.
To be of most use, the two Mailtraq machines should be on different parts of the Internet - served by different ISPs and backbones. Naturally both Mailtraqs should have permanent connections to the Internet.
Download mailmonitor.zip (version 1.1)
Setting up the Monitor machine
The monitor machine is the machine which will receive the regular feed of messages, and raise an alert if the feed is interrupted.
Install a copy of Mailtraq.
In Mailtraq, create a user 'mailmonitor', with a mailbox also called 'mailmonitor'.
In the properties of this mailbox, on the Gateway tab, check the 'Gateway to KA9Q and Text Files' option, and set the Gateway directory to
C:\Program Files\Mailtraq\mailmonitor\monitor
Unzip mailmonitor.zip, to obtain a folder 'mailmonitor' with various subfolders and files:
Move this folder and its contents into C:\Program Files\Mailtraq\
The mailmonitor\emails\alert.txt file contains an email to be sent in the event of a failure of the monitored system:
FROM: postmaster@[127.0.0.1] RCPT: admin@yourdomain.com From: Mail Server Alert <postmaster@[127.0.0.1]> Subject: ALERT: Mail transfer failure X-Mailer: Enstar MailMonitor Utility MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable
This is an automated message to inform you that the oubound mail feed from your mail server has been interrupted.
The reason for this is unknown - the problem may be with the mail server, the connection to the Internet, or with the Service Provider.
|
Open this file in Notepad and customise the message for your needs - identifying the mailserver being monitored, and changing the email address given in the RCPT line. Be careful to avoid sending this message to an address being managed by the monitored system, or the alert is unlikely to get through. You may wish to send the alert to an email address routed to your cellphone or pager.
Now you can start monitoring.
To do this, run the mailmonitor.bat batch file.
You may want to create a shortcut to your startup group (or use another mechanism) to ensure the monitor is always running.
After 20 minutes the system will send an alert email. Check that this alert is received where you expect it to be. The system will not send any further alerts until the feed of emails is started, and subsequently interrupted.
Setting up the Mailtraq being monitored
This is the machine to be monitored, with a copy of Mailtraq already installed and configured.
On this machine the mailmonitor kit will be used to generate a regular feed of trace messages.
Unzip mailmonitor.zip, to obtain a folder 'mailmonitor' with various subfolders and files:
Move this folder and its contents into C:\Program Files\Mailtraq\
The mailmonitor\emails\trace.txt file contains an email to be sent to the other machine every five minutes:
FROM: postmaster@[127.0.0.1] RCPT: mailmonitor@monitoringdomain.net From: Mail Server Alert <postmaster@[127.0.0.1]> Subject: ALERT: Mail transfer failure X-Mailer: Enstar MailMonitor Utility MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable
This message is being sent automatically every five minutes. If these messages are delayed then the remote monitoring system will raise an alert. |
Open this file in Notepad and customise the message for your needs - changing the email address given in the RCPT line to match the domain of the machine providing the monitoring service.
Now you can start sending the emails.
To do this, run the mailfeed.bat batch file.
You may want to create a shortcut to your startup group (or use another mechanism) to ensure the feed is always running.
The system will inject emails into Mailitraq every five minutes. If they are delayed then, after about 15 minutes an alert will be raised by the monitoring machine.
It may seem tempting to try to speed up the system - for example to send trace emails every minute - but this is likely to cause a large number of false alarms as short delays are an everyday factor in email transmissions.
Installation options
The setup instructions above cover the simplest case, however there are other ways you can use it:
- This utility can be setup by two systems to monitor each other
- One system can be setup to monitor several systems
- One Mailtraq can be monitored by several different monitoring systems (simply add more RCPT: lines to the trace.txt file)