This is why I ended up with problems. I was trying to put together several mods I wrote for the board and I got mixed up with my subroutine names.
I'll try to give you something that changes as little as possible of what you have.
First, you need to set the email field. This would go somewhere in your .cfg file:
Code:
# Fieldname that contains the email address of the user
$db_email_field = 'Email';
Then replace the following subroutine:
Code:
sub send_email {
# --------------------------------------------------------
my ($i,$message,@lines,$line,$count,%rec,$mail_count);
unless ($admin_email) { $message = "Admin email has not been entered in the .cfg file<BR>"; }
unless ($admin_email =~ /.+\@.+\..+/) { $message = "Admin email address is not in the correct format.<BR>"; }
unless ($in{'subject'}) { $message .= "You must fill in a subject for your message.<BR>"; }
unless ($in{'emailmessage'}) { $message .= "Your email message is empty.<BR>"; }
for ($i = 0; $i <= $#db_cols; $i++) {
if ($db_email_field eq $db_cols[$i]) {
$found = 1;
last;
}
}
if (!$found) {
$message .= "email field not found<BR>";
}
open (DB, "<$db_file_name") or &cgierr("error in mass_mail. unable to open database: $db_file_name.\nReason: $!");
@lines = <DB>;
close DB;
$in{'mh'} = $#lines + 1;
my ($status, @hits) = &query("view");
unless ($status eq 'ok') {
$message .= "$status<BR>";
}
if ($message) {
chomp($message);
&html_send_email_form($message);
return;
}
my ($numhits) = ($#hits+1) / ($#db_cols+1);
for (0 .. $numhits - 1) {
%rec = &array_to_hash($_, @hits);
if ($rec{$db_email_field} =~ /.+\@.+\..+/) {
open (MAIL, "$mailprog") || &cgierr("unable to open mail program");
print MAIL "To: $rec{$db_email_field}\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: $in{'subject'}\n\n";
print MAIL "-" x 75 . "\n\n";
print MAIL $in{'emailmessage'};
close (MAIL);
}
}
&html_send_email_success;
}
This doesn't count the number that were sent. That would require a change to the html file as well.
JPD
----------------------------------------------------
JPDeni's DBMan-ual How to
ask questions the smart way.