Solved

Scripting E-Mail Notifications

Posted on 2004-04-27
9
191 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
  • 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
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…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now