I have the cgi file but want to do it in php rather than cgi.
Here is the code that i use to followup on reciepents and send them messages.
My headack is that i would need to send more than one record from the request file in one email to each recipient.
#!/usr/bin/perl
#############################################################
use Time::Local;
use CGI qw (:standard);
$time = time();
$form = new CGI;
$ip = $form->remote_host();
$realdate = &getdate;
require "/home/bidvirmy/public_html/cgi-bin/config.pl";
&connect_sql;
print $form->header;
print qq|<html><body>|;
$SQL = "SELECT ID FROM recipients";
&my_sql2;
while ($column = $sth->fetchrow_hashref){
$field = $column->{'ID'};
push(@results, $field);
}
$sth->finish;
foreach $results(@results){
$SQL = "SELECT * FROM recipients WHERE ID='$results'";
&my_sql;
while ($column = $sth->fetchrow_hashref){
&recipient_variables;
}
$sth->finish;
$SQL = "SELECT fromname,fromemail,signature FROM setup";
&my_sql;
while ($column = $sth->fetchrow_hashref){
$fromname = $column->{'fromname'};
$fromemail = $column->{'fromemail'};
$signature = $column->{'signature'};
}
$sth->finish;
$SQL = "SELECT delay,subject,message FROM messages WHERE listid='$listid'";
&my_sql;
while ($column = $sth->fetchrow_hashref){
$delay = $column->{'delay'};
$subject = $column->{'subject'};
$message = $column->{'message'};
$subject =~ s/<firstname>/$firstname/g;
$subject =~ s/<lastname>/$lastname/g;
$subject =~ s/<date>/$realdate/g;
$message =~ s/<firstname>/$firstname/g;
$message =~ s/<lastname>/$lastname/g;
$message =~ s/<email>/$email/g;
$message =~ s/<date>/$realdate/g;
$subject =~ s/\\'/\'/g;
$message =~ s/\\'/\'/g;
$sendtime = (($delay * 86400) + $addtime);
$senddate = &date($sendtime);
if ($senddate eq $realdate){
open (MAIL, "| $sendmail -t") || die "I can't open sendmail\n";
print MAIL "To: $firstname $lastname <$email>\n";
print MAIL "From: $fromname <$fromemail>\n";
print MAIL "Subject: $subject\n";
print MAIL "Content-Type: text/plain\n";
print MAIL "Content-Transfer-Encoding: 7bit\n";
print MAIL "\n";
print MAIL qq|$message
$signature
To remove yourself from this list, click on this link:
$removeurl?ID=$ID
|;
close MAIL;
}
}
$sth->finish;
}
print qq|Done - $time</body></html>|;
exit;
################### DATE ROUTINES ###################
sub getdate {
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime(time());
my (@months) = qw!January February March April May June July August September October November December!;
($day < 10) and ($day = "0$day");
$year = $year + 1900;
return "$months[$mon] $day, $year";
}
sub date {
@monthnames = ("January","February","March","April","May","June","July","August","September","October","November","December");
($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($_[0]);
$month = $monthnames[$mon];
($day < 10) and ($day = "0$day");
$year = $year + 1900;
return "$month $day, $year";
}