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
sub doit {
13 rodolico 4
   my ( $parameters, $message ) = @_;
2 rodolico 5
   my %CLIParams ;
6
   $CLIParams{'-f'}  = qq/$$parameters{'mailFrom'}/    if $$parameters{'mailFrom'};
7
   $CLIParams{'-t'}  = qq/$$parameters{'mailTo'}/      if $$parameters{'mailTo'};
8
   $CLIParams{'-u'}  = qq/$$parameters{'mailSubject'}/ if $$parameters{'mailSubject'};
9
   $CLIParams{'-s'}  = qq/$$parameters{'mailServer'}/  if $$parameters{'mailServer'};
10
   $CLIParams{'-xu'} = qq/$$parameters{'smtpUser'}/    if $$parameters{'smtpUser'};
5 rodolico 11
   $CLIParams{'-xp'} = qq/$$parameters{'smtpPass'}/    if $$parameters{'smtpPass'};
2 rodolico 12
   $CLIParams{'-cc'} = qq/$$parameters{'mailCC'}/      if $$parameters{'mailCC'};
13
   $CLIParams{'-bcc'}= qq/$$parameters{'mailBCC'}/     if $$parameters{'mailBCC'};
14
   $CLIParams{'-l'}  = qq/$$parameters{'logFile'}/     if $$parameters{'logFile'};
5 rodolico 15
   $CLIParams{'-a'}  = qq/$$parameters{'attachment'}/     if $$parameters{'attachment'};
16
   $CLIParams{'-o tls='} = qq/$$parameters{'tls'}/     if $$parameters{'tls'};
2 rodolico 17
 
5 rodolico 18
 
13 rodolico 19
   $commandLine = $$parameters{'sendEmailScriptLocation'};
2 rodolico 20
   die "Could not find executable $commandLine in sendEmailScript\n" unless -x $commandLine;
21
   foreach my $key ( keys %CLIParams ) {
5 rodolico 22
      # depending on whether the key ends in an = or not, we will or will not use a space
23
      # between the key and the parameter
24
      $commandLine .= $key =~ m/=$/ ? " $key'$CLIParams{$key}'" : " $key '$CLIParams{$key}'";
2 rodolico 25
   }
26
   $commandLine .= ' ' . $$parameters{'otherCLParams'} if $$parameters{'otherCLParams'};
5 rodolico 27
#   print "$commandLine\n\n";
28
#   print $message;
29
#   return;
2 rodolico 30
   open SENDMAIL, "|$commandLine" or die "Could not open [$commandLine]: $!\n";
31
   print SENDMAIL $message;
32
   close SENDMAIL;
33
}
34
 
13 rodolico 35
1;