Blat is a command line email client. You can easily use Blat to send an email when a service crashes / terminates (and FireDaemon restarts it) or when your service is stopped via a FireDaemon Post Service event. The application can be run as a Windows Service using FireDaemon Pro, which lets you start the application automatically at boot prior to login, start multiple instances of the application and more. This HOWTO will show you how to set it up. You can also use FireDaemon Fusion to manage FireDaemon and other Windows services via a web browser.
Blat Setup Under FireDaemon Pro
First thing you will need is Blat, a command line / scriptable email client. It's free to use and you can download it from the official website here. Download the Blat ZIP file from SourceForge and unpack it into the directory of your choice. For the purposes of this HOWTO, we have downloaded Blat to C:\blat3211.
Download and install FireDaemon Pro into the directory of your choice, typically C:\Program Files\FireDaemon.
Next start the FireDaemon GUI from the desktop shortcut. Click on the "Create a new service definition" button in the toolbar (or type Ctrl+N) and enter the information into the fields as you see below. Adjust the paths to suit your installation and the application you wish to receive email alerts about.
In the screenshot below we have set up a service to run the Calculator (calc.exe):
- Executable: The path to the application you wish to run. In this calculator example, the path is C:\Windows\System32\calc.exe.
- Working Directory: The directory containing the application you wish to run. In this calculator example, the path is C:\Windows\System32.
- Parameters: None. The application of your choice may require parameters to run. Consult your application's documentation or our HOWTO guides to learn more about specific application parameters.
Next, go to the Pre/Post-Service tab and add a Post-Service Program as per the two screenshots below. Select "Insert" from the Post-Service Programs menu.
Here we have unzipped Blat into the folder C:\blat3211. Make sure your Post-Service program is run After Event and ensure you allow plenty of time for Blat to run (i.e. 10000ms or more) since it has to connect to your MTA and inject the message.
- Executable: The path to your blat.exe file. For the purposes of this HOWTO, the path is C:\blat3211\full\blat.exe.
- Working Directory: The directory containing your blat.exe file. For the purposes of this HOWTO, the path is C:\blat3211\full.
- Execution Time: The time, in milliseconds, to wait before running Blat. Here we have specified 10000 ms.
- Run Program: Select "After Event" from the options.
The complete Blat parameters list reads: -to firstname.lastname@example.org -subject "Service Restarted or Stopped" -body "My test service crashed and was restarted or was stopped" -server mail.mysmtprelay.com -f email@example.com -u name -pw pass
- -to Specifies who the email is to be delivered to.
- -subject Is the email subject line. Use quotes if there are spaces.
- -body Is the body of the email. Again, use quotes. You can also use a text file. See the Blat document for more info.
- -server Is your SMTP relay.
- -f Is who the email is from
- -u Is the email username
- -pw Is the email password
-u and -pw are usually required for authenticated relaying but you will probably not need them.Modify the parameters above to suit your installation and test your Blat and FireDaemon setup!