Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

Scripting E-Mail Notifications

I would like to set up a batch file or script that will send out an e-mail when a Win2k server service goes down. Does anyone have any experience with scripting e-mail notifications? We are in an Win2k Ad enviornment using Exchange 2000.  
Thanks in advance for your feedback.
0
mmcginley
Asked:
mmcginley
  • 4
  • 2
2 Solutions
 
TheImmortalCommented:
One of the easier things to do would be to write a simple Java Program that either used sockets directly or the JavaMail (SMTP) library.  The Batch file would call this program passing in whatever parameters the program needed.

Conversely, if you have a web server running (on the monitoring machine or elsewhere) while a FORM that submit mail (EG FormMail CGI), you could simply access the Form's URL from the batch file:

EG:
  http://myserver/servicedown.cgi?Subject=Outage&Service=MyService
0
 
mmcginleyAuthor Commented:
Thanks IMMORTAL.
I actually am just looking for a batch command or script that simply sends a basic e-mail when executed. So that when one of my Win2K server Services experiences a failure, one of the recovery options can be to execute this file to send us an e-mail notification.
Thanks again.
0
 
TheImmortalCommented:
Try this then, microsoft created this port of Sendmail for Windows:

ftp://ftp.microsoft.com/developr/drg/unix-to-windows/ports/Sendmail/

This program will allow you to sendmail from the batch file without writing any other in house mail programs.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
TheImmortalCommented:
PS: The archive comes complete with source code an other projects.  Use WinZIP to decompress the archive and the .TAR file inside (extract the TAR then open it with WinZIP or some other ZIP reading tool).  The Sendmail.exe is in the TAR file.
0
 
FishMongerCommented:
Using a batch file would not be a very good choice for sending emails.  You should use one of the more powerfull scripting languages such as Perl, VB, Java, etc.  My preference would be to use Perl and one of its mail modules.  Here's a short Perl email script.

#!perl -w

use strict;
use MIME::Lite;
my $service = shift;  # Name of service that went down passed to the script as an argument.

MIME::Lite->send('smtp', "smtp.myisp.net", Timeout=>60);

my $msg = MIME::Lite->new(
                  From      =>  'me@myhost.com',
                  To          =>  'you@yourhost.com',
                  Cc          =>  'some@other.com, some@more.com',
                  Subject  =>  'Server Service',
                  Data       =>  "$service service went down"
                  );

$msg->send;


http://www.activestate.com/Products/ActivePerl/?_x=1
http://search.cpan.org/~yves/MIME-Lite-3.01/lib/MIME/Lite.pm
0
 
TheImmortalCommented:
You would still have to invoke the Perl script through a Batch file or something.  Sendmail for Windows is perfectly viable.
0
 
FishMongerCommented:
I'm not sure what you mean by your first statement; wouldn't the batch file and sendmail need to be invoked by something?  I never said that Sendmail for Windows wasn't a viable option, but it still nees to be invoked by a batch file, or something.  In fact, it could be invoked within the Perl script instead of the MIME::Lite module.  BTW, your link doesn't work (at least it doesn't for me).  As I understand it, mmcginley is using some method to monitor the runnng services and if one of them stops/fails, he/she wants to call a batch file that either directly or indirectly sends an email message.  Personally, I'd combine those steps into 1 Perl script, but it can also be done with one of other scripting languages.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now