Subversion Repositories camp_sysinfo_client_3

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 rodolico 1
#! /usr/bin/perl -w
2
 
3
my $application = 'sendEmail.pl'; # assumed to be located in the scripts directory
4
 
5
sub doit {
6
   my ( $parameters, $message, $scriptDirectory ) = @_;
7
   my %CLIParams ;
8
   $CLIParams{'-f'}  = qq/$$parameters{'mailFrom'}/    if $$parameters{'mailFrom'};
9
   $CLIParams{'-t'}  = qq/$$parameters{'mailTo'}/      if $$parameters{'mailTo'};
10
   $CLIParams{'-u'}  = qq/$$parameters{'mailSubject'}/ if $$parameters{'mailSubject'};
11
   $CLIParams{'-s'}  = qq/$$parameters{'mailServer'}/  if $$parameters{'mailServer'};
12
   $CLIParams{'-xu'} = qq/$$parameters{'smtpUser'}/    if $$parameters{'smtpUser'};
13
   $CLIParams{'-xp'} = qq/$$parameters{'smtpUser'}/    if $$parameters{'smtpUser'};
14
   $CLIParams{'-cc'} = qq/$$parameters{'mailCC'}/      if $$parameters{'mailCC'};
15
   $CLIParams{'-bcc'}= qq/$$parameters{'mailBCC'}/     if $$parameters{'mailBCC'};
16
   $CLIParams{'-l'}  = qq/$$parameters{'logFile'}/     if $$parameters{'logFile'};
17
 
18
   $commandLine = $scriptDirectory . $application;
19
   die "Could not find executable $commandLine in sendEmailScript\n" unless -x $commandLine;
20
   foreach my $key ( keys %CLIParams ) {
21
      $commandLine .= " $key '$CLIParams{$key}'"
22
   }
23
   $commandLine .= ' ' . $$parameters{'otherCLParams'} if $$parameters{'otherCLParams'};
24
   #print "$commandLine\n\n";
25
   #print $message;
26
   #return;
27
   open SENDMAIL, "|$commandLine" or die "Could not open [$commandLine]: $!\n";
28
   print SENDMAIL $message;
29
   close SENDMAIL;
30
}
31
 
32
1;