Good Morning Carol...having a bit of a problem inserting a mail routine script into the sub delete_records routine. I want a "Confirmation of record Deletion" to be send for single or multiple deletions. Where to insert mail script and how to capture $rec{'Email'} from each form... your input is appreciated..thanks Rob
Apr 27, 2000, 10:57 AM
Veteran / Moderator (8669 posts)
Apr 27, 2000, 10:57 AM
Post #3 of 7
Views: 2823
If you haven't already done so, add the following to your .cfg file:
$mailprog = "|/usr/lib/sendmail -t -oeq";
# Your email address
$admin_email = 'you@yourserver.com';
# This is the field position in the database used for storing
# the email address of the one who owns the record. Set to -1 if not used.
$auth_email_field = 4;
In db.cgi, sub delete_records, change
($delete_list{$data[$db_key_pos]} = 0) : # then mark it deleted and don't print it to the new database.
($output .= $line . "\n"); # otherwise print it.
to
$delete_list{$data[$db_key_pos]} = 0; # then mark it deleted and don't print it to the new database.
open (MAIL, "$mailprog") or &cgierr("Can't start mail program");
print MAIL "To: $data[$auth_email_field]\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: $html_title Confirmation of Deleted Record\n\n";
print MAIL "-" x 75 . "\n\n";
print MAIL "Your record at $html_title, which had the following information:\n";
for ($i=0;$i<=$#db_cols ;++$i) {
print MAIL "$db_cols[$i]: $data[$i]\n";
}
print MAIL "\nhas been deleted from the database.\n\n";
close MAIL;
}
else {
$output .= $line . "\n"; # otherwise print it.
}
This will send out individual email messages for each record that is deleted. I don't know how to combine multiple records for the same user in one email message.
------------------
JPD
Code:
# Full path to sendmail on your system $mailprog = "|/usr/lib/sendmail -t -oeq";
# Your email address
$admin_email = 'you@yourserver.com';
# This is the field position in the database used for storing
# the email address of the one who owns the record. Set to -1 if not used.
$auth_email_field = 4;
In db.cgi, sub delete_records, change
Code:
$delete_list{$data[$db_key_pos]} ? # if this id is one we want to delete ($delete_list{$data[$db_key_pos]} = 0) : # then mark it deleted and don't print it to the new database.
($output .= $line . "\n"); # otherwise print it.
to
Code:
if ($delete_list{$data[$db_key_pos]}) { $delete_list{$data[$db_key_pos]} = 0; # then mark it deleted and don't print it to the new database.
open (MAIL, "$mailprog") or &cgierr("Can't start mail program");
print MAIL "To: $data[$auth_email_field]\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: $html_title Confirmation of Deleted Record\n\n";
print MAIL "-" x 75 . "\n\n";
print MAIL "Your record at $html_title, which had the following information:\n";
for ($i=0;$i<=$#db_cols ;++$i) {
print MAIL "$db_cols[$i]: $data[$i]\n";
}
print MAIL "\nhas been deleted from the database.\n\n";
close MAIL;
}
else {
$output .= $line . "\n"; # otherwise print it.
}
This will send out individual email messages for each record that is deleted. I don't know how to combine multiple records for the same user in one email message.
------------------
JPD
Apr 27, 2000, 1:16 PM
Veteran / Moderator (8669 posts)
Apr 27, 2000, 1:16 PM
Post #5 of 7
Views: 2817
Which counter mod did you install? The one with the Top Ten has a variable called "$counter_dir" which makes it so you only have to enter the directory path once.
If you don't have it in your .cfg file, add
$counter_dir = $db_script_path . "/temp";
Then, in sub delete_records, after
close MAIL;
add
It won't matter if there isn't a file there. But if there is, it will delete the file.
------------------
JPD
If you don't have it in your .cfg file, add
$counter_dir = $db_script_path . "/temp";
Then, in sub delete_records, after
close MAIL;
add
Code:
unlink "$counter_dir/$data[$db_key_pos]";It won't matter if there isn't a file there. But if there is, it will delete the file.
------------------
JPD
Feb 10, 2003, 5:05 PM
User (120 posts)
Feb 10, 2003, 5:05 PM
Post #6 of 7
Views: 2804
I have added this rountine to my cgi. I cannot for the life of me figure out what I am doing wrong.
I copied it exactly. & the only thing I did change was the "To" area. My auth admin is not used it is as -1. So, I just put in the email address it is to always go to. But, no matter what I get an internal error each time.
Can you see anything I am doing wrong? :(
CODE:
if ($delete_list{$data[$db_key_pos]}) {
$delete_list{$data[$db_key_pos]} = 0; # then mark it deleted and don't print it to the new database.
open (MAIL, "$mailprog") or &cgierr("Can't start mail program");
print MAIL "To: raeana\@newoutriders.com\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: $html_title Confirmation of Deleted Record\n\n";
print MAIL "-" x 75 . "\n\n";
print MAIL "Your record at $html_title, which had the following information:\n";
for ($i=0;$i<=$#db_cols ;++$i) {
print MAIL "$db_cols[$i]: $data[$i]\n"; }
print MAIL "\nhas been deleted from the database.\n\n";
close MAIL;
}
else {
$output .= $line . "\n"; # otherwise print it.
}
Diana Rae
I copied it exactly. & the only thing I did change was the "To" area. My auth admin is not used it is as -1. So, I just put in the email address it is to always go to. But, no matter what I get an internal error each time.
Can you see anything I am doing wrong? :(
CODE:
if ($delete_list{$data[$db_key_pos]}) {
$delete_list{$data[$db_key_pos]} = 0; # then mark it deleted and don't print it to the new database.
open (MAIL, "$mailprog") or &cgierr("Can't start mail program");
print MAIL "To: raeana\@newoutriders.com\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: $html_title Confirmation of Deleted Record\n\n";
print MAIL "-" x 75 . "\n\n";
print MAIL "Your record at $html_title, which had the following information:\n";
for ($i=0;$i<=$#db_cols ;++$i) {
print MAIL "$db_cols[$i]: $data[$i]\n"; }
print MAIL "\nhas been deleted from the database.\n\n";
close MAIL;
}
else {
$output .= $line . "\n"; # otherwise print it.
}
Diana Rae