sub parse_mail { my $mail = $_[0]; # print $mail; open "MAIL","<$mail" || die "Cannot open $mail, $!"; @mailf = ; chomp (@mailf); my $line; # foreach $line (@mailf) { # print "$line\n"; # } print @mailf; close MAIL || die "Cannot close $mail, $!"; # return @mailf; } #### #!/usr/gnu/bin/perl -w # # ################################################################################ use strict; no strict "refs"; use Mail::Sender; my $f2dir = "C:\\windows\\desktop\\tmp\\"; #print "$f2dir\n"; my @names = <$f2dir*.f2mail>; my @mailf; my $file; foreach $file (@names) { if ( (! -d $file) && ($file =~ /\b\.f2mail/) ) { parse_mail($file); }else{ print "Error with $file, $!"; } sender_mail(@mailf); file_clean($mailf[3],$mailf[4],$file); } ############################################################################### # Begin Subroutines # # parse_mail parses the parameter file (*.f2mail) and submits the results to # Mail::Sender for smtp ############################################################################### sub parse_mail { my $mail = $_[0]; # print $mail; open "MAIL","<$mail" || die "Cannot open $mail, $!"; @mailf = ; chomp (@mailf); my $line; # foreach $line (@mailf) { # print "$line\n"; # } print @mailf; close MAIL || die "Cannot close $mail, $!"; # return @mailf; } ############################################################################### # # sender_mail calls the Mail:Sender module and prepares for smtp ############################################################################### sub sender_mail { my @mailf = @_; print $mailf[3]; open (BODY,$mailf[3]) || die "Cannot open $mailf[3], $!"; my @body = ; close (BODY) || die "Cannot close $mailf[3], $!"; my $sender; ref ($sender = new Mail::Sender ({ from => $mailf[2], smtp => 'humap.segrest.com'})) || die "Sender error: $sender, $Mail::Sender::Error!\n"; ref (($sender->MailFile( {to => $mailf[0], subject => $mailf[1], msg => "@body", file => $mailf[4]}))) || die "Sender error, $sender, $Mail::Sender::Error!, $!"; return 1; } ############################################################################### # # file_clean unlinks the files specified in the parameter file (*.f2mail) and # the parameter file itself ############################################################################### sub file_clean { my $file; foreach $file (@_) { unlink $file || die "Unlink failure: $!"; } return 1; } #### Where ever there is confusion to be had... I'll be there.