Subversion Repositories camp_sysinfo_client_3

Rev

Rev 5 | Rev 13 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

#! /usr/bin/perl -w

my $application = 'sendEmail.pl'; # assumed to be located in the scripts directory

sub doit {
   my ( $parameters, $message, $scriptDirectory ) = @_;
   my %CLIParams ;
   $CLIParams{'-f'}  = qq/$$parameters{'mailFrom'}/    if $$parameters{'mailFrom'};
   $CLIParams{'-t'}  = qq/$$parameters{'mailTo'}/      if $$parameters{'mailTo'};
   $CLIParams{'-u'}  = qq/$$parameters{'mailSubject'}/ if $$parameters{'mailSubject'};
   $CLIParams{'-s'}  = qq/$$parameters{'mailServer'}/  if $$parameters{'mailServer'};
   $CLIParams{'-xu'} = qq/$$parameters{'smtpUser'}/    if $$parameters{'smtpUser'};
   $CLIParams{'-xp'} = qq/$$parameters{'smtpPass'}/    if $$parameters{'smtpPass'};
   $CLIParams{'-cc'} = qq/$$parameters{'mailCC'}/      if $$parameters{'mailCC'};
   $CLIParams{'-bcc'}= qq/$$parameters{'mailBCC'}/     if $$parameters{'mailBCC'};
   $CLIParams{'-l'}  = qq/$$parameters{'logFile'}/     if $$parameters{'logFile'};
   $CLIParams{'-a'}  = qq/$$parameters{'attachment'}/     if $$parameters{'attachment'};
   $CLIParams{'-o tls='} = qq/$$parameters{'tls'}/     if $$parameters{'tls'};
   
   
   $commandLine = $scriptDirectory . $application;
   die "Could not find executable $commandLine in sendEmailScript\n" unless -x $commandLine;
   foreach my $key ( keys %CLIParams ) {
      # depending on whether the key ends in an = or not, we will or will not use a space
      # between the key and the parameter
      $commandLine .= $key =~ m/=$/ ? " $key'$CLIParams{$key}'" : " $key '$CLIParams{$key}'";
   }
   $commandLine .= ' ' . $$parameters{'otherCLParams'} if $$parameters{'otherCLParams'};
#   print "$commandLine\n\n";
#   print $message;
#   return;
   open SENDMAIL, "|$commandLine" or die "Could not open [$commandLine]: $!\n";
   print SENDMAIL $message;
   close SENDMAIL;
}

1;

Generated by GNU Enscript 1.6.5.90.