Here's the sub..Its pretty simple. Its supposed to send emails and show
the
"Sent emails " page right away but it seems the page is being displayed a
substantial time later after it seems the emails are sent but I'm expecting
it to appear almost right away because of forking. It appears there's a
forking process happening.
Thanks
Dexter
sub adminsendall
{
$pid= fork();
if($pid==0)
{
my $dbh = $drh->connect( $multidbname,$dbusername,$dbpassword ) or die
"Unable to connect to Product Category database";
$sth = $dbh->prepare("select * from members ");
$sth->execute;
my $row_hash;
$i=0;
while($row_hash = $sth->fetchrow_hashref)
{
$email= $row_hash->{email};
$firstname= $row_hash->{adminoverride};
open(MAIL,"|$mailprog -t") || die "cant open $mailprog";
print MAIL "To: $email\n";
print MAIL "From: $adminemail\n";
print MAIL "Subject: $subject\n";
print MAIL "Hi $firstname\n\n";
print MAIL $message;
close(MAIL);
$i=$i+1;
}
$sth->finish;
$dbh->disconnect;
exit;
}
else{ print $page->header;
print "<html><head><title>Online Greeting Cards</title>";
print " </head><body>";
print"<center><b>Your Emails have been sent</center></b>";
print "</body></html>";
exit;
}
}