Solved

Scripting E-Mail Notifications

Posted on 2004-04-27
9
195 Views
Last Modified: 2010-04-17
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
Comment
Question by:mmcginley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
9 Comments
 
LVL 2

Expert Comment

by:TheImmortal
ID: 10928817
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
 

Author Comment

by:mmcginley
ID: 10929180
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
 
LVL 2

Accepted Solution

by:
TheImmortal earned 63 total points
ID: 10929231
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
Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

 
LVL 2

Expert Comment

by:TheImmortal
ID: 10929253
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
 
LVL 28

Assisted Solution

by:FishMonger
FishMonger earned 62 total points
ID: 10930348
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
 
LVL 2

Expert Comment

by:TheImmortal
ID: 10930849
You would still have to invoke the Perl script through a Batch file or something.  Sendmail for Windows is perfectly viable.
0
 
LVL 28

Expert Comment

by:FishMonger
ID: 10932385
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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an explanation of a simple data model to help parse a JSON feed
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question