Last month I’ve written an article on executing any file when application crashed or stopped running. All I need is a small portable software that monitors for a process availability. When the process crashed, the monitoring software will automatically run a batch file containing a few more commands to run. A game server with intensive mod can cause daily random crashes and it’s important to make sure that it auto restarts the game server when that happens. So far everything is working as expected except it’d have been better if I can include an email or SMS notification when the server crashes.
Command line email blat
In order to do that, I found a small portable tool called Blat which can send an email using command line. Blat is a Win32 command line utility that sends eMail using SMTP or post to usenet using NNTP. Command line application is very different from graphical user interface (GUI). In programs with GUI, there are buttons and boxes for you to enter the details but for command line, everything must be typed out in a single line. It’s not so user friendly but very flexible.

To use Blat to send email, you will definitely need to refer to the syntax manual. Below is an example for a normal SMTP server that requires authentication. You can also use IP:Port for -server syntax. By default Blat uses port 25 but if your SMTP server uses a different port, then you can change it.

blat.exe -f from@email.com -to recipient@email.com -subject ThisIsTheSubject -body ThisIsTheBody -server smtp.server.com:25 -u SMTPUserLogin -pw SMTPUserPass

Using the command line above, I will receive an email notification alert whenever the server goes down. If I want to receive it in a form of SMS on my mobile, I will need subscribe “email to SMS” service from Clickatell, World-Text or any other provider that offers such service.

There hasn’t been any updates on Blat for more than 2 years but I can verify that it works without any problems on my webhosting SMTP server. However I don’t think you can use Gmail, Hotmail, and Yahoo SMTP to send out email because this 3 email service requires SSL and I can’t find this option in Blat. You can try SendEmail which supports TLS but you will first need to install the Net::SSLeay and IO::Socket::SSL perl modules on Windows.

[ Visit Blat Official Homepage ]

Technorati Tags: , , , ,