#!/usr/bin/perl -I /usr/local/httpd/cgi-bin # WARNING - HARDCODED VALUES. # resend-notify-emails.pl # this script is for the purpose of resnding emails, # that either were not actually sent by the system, # or got lost. # These emails must have been logged in the folder notify # in the clients primary folder. # For example: # Without the leading pound signs, # The first few lines in the files look like this: # From:autonotify.usnscc@actscorp.com # To: sbunting@navyleague.org,bcarico@actscorp.com # Subject: Completed: James Baumann # The only parameter is the filename of # the file in the notify folder. # The client-id is hardcoded. # HARDCODED Values. $ENV{DOCUMENT_ROOT} = "/home/hivy/TestManager-Trunk/Testmanager/htdocs" ; $ENV{DOCUMENT_ROOT} = "/usr/local/httpd/htdocs" ; local $Client_ID = "sandbox" ; local $Client_ID = "usnscc" ; local $Sleep_Time = 301 ; require 'sitecfg.pl'; # The above also includes the maillib.pl script. if ($#ARGV < 0) { warn "No parameter on the command line.\n" ; die "Usage: resend-notify-emails.pl EmailFileName\n" ; } local $error_Cnt = 0; local $mail_file ; foreach $file_name (@ARGV) { # warn "Email file name is $file_name\n" ; $mail_file = join( $pathsep, $pubroot, $Client_ID, "notify", $file_name); unless (-r $mail_file && -f _ && -s _) { warn "Full email path: $mail_file\n" ; warn "Full email path is either not readable, not a regular file, or is empty.\n" ; $error_Cnt ++ ; } } if ($error_Cnt) { die "ERROR: One or more files is inaccessible.\n" ; } foreach $file_name (@ARGV) { # warn "Email file name is $file_name\n" ; local ($From, $To_Addrs, $Subject, $Text) ; local @Entire_File ; local ($result ) ; $mail_file = join( $pathsep, $pubroot, $Client_ID, "notify", $file_name); $result = open FHAND, $mail_file ; die "ERROR: file $mail_file by " . ($! + 0) . " $! " unless ($result) ; @Entire_File = ; close FHAND ; $From = shift @Entire_File ; # Get the first line. $To_addrs = shift @Entire_File ; $Subject = shift @Entire_File ; chomp $From ; $From =~ s/^From:// ; chomp $To_addrs ; $To_addrs =~ s/^To:\s*// ; chomp $Subject ; $Subject =~ s/^Subject:\s*// ; $Text = join "", @Entire_File ; &send_mail ( $From, $To_addrs, $Subject, $Text) ; print "DONE: $file_name from $From TO $To_addrs About $Subject \n" ; sleep $Sleep_Time ; }