#!/usr/bin/perl use DBI();
my $counter = 0;
my @email;
my $dbh = DBI->connect("DBI:mysql:database=<db>;host=<ip>", "<username>", "<password>", {'RaiseError' => 1});
my $query = "SELECT fname, lname, homeemail, officeemail FROM people WHERE current=1";
my $sth = $dbh->prepare($query);
$sth->execute();
@email = <STDIN>;
while(my $ref = $sth->fetchrow_hashref()) { if($ref->{homeemail} ne "NULL" && $ref->{homeemail} ne "") { open PIPE, "| /var/qmail/bin/qmail-inject $ref->{homeemail}"; foreach my $line (@email) { $line =~ s/^To: .+$/To: \"$ref->{fname} $ref->{lname}\" <$ref->{homeemail}>/; print PIPE "$line"; } close PIPE; } if($ref->{officeemail} ne "NULL" && $ref->{officeemail} ne "") { open PIPE, "| /var/qmail/bin/qmail-inject $ref->{officeemail}"; foreach my $line (@email) { $line =~ s/^To: .+$/To: \"$ref->{fname} $ref->{lname}\" <$ref->{officeemail}>/; print PIPE "$line"; } close PIPE; } }
$sth->finish(); $dbh->disconnect();
-- Andrew Gaffney
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>