Gossamer Forum
Home : Products : Links 2.0 : Customization :

Sending Email Problem

Quote Reply
Sending Email Problem
Hi, can anybody tell me whats wrong with this code. I get an error message saying bad email

sub holdval_delete_records {
# --------------------------------------------------------
# Deletes a single or multiple records. First the routine goes thrrough
# the form input and makes sure there are some records to delete. It then goes
# through the database deleting each entry and marking it deleted. If there
# are any keys not deleted, an error message will be returned saying which keys
# were not found and not deleted, otherwise the user will go to the success page.

my ($key, Þlete_list, $rec_to_delete, @data, $errstr, $succstr, $output, %links, @lines, $id, $first, $last, $rec_to_reenter, %reenter_list, %hold_list, @holdhits, $numhits, $counter);

$rec_to_delete = 0;
foreach $key (keys %in) { # Build a hash of keys to delete.
if ($in{$key} eq "delete") {
$delete_list{$key} = 1;
$rec_to_delete = 1;
}
}
$rec_to_delete or (&html_generic("Error: $html_object(s) Not Deleted", "no records specified.") and return);

# Search the database for a record to delete.
open (DB, "<$db_hold_name") or &cgierr("error in delete_records. unable to open db file: $db_hold_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB>) {
(/^#/) and ($output .= $_ and next LINE);
(/^\s*$/) and next LINE;
chomp;
@data = &split_decode($_);

$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 .= "$_\n"); # otherwise print it.
}
close DB;

# Reprint out the database.
open (DB, ">$db_hold_name") or &cgierr("error in delete_records. unable to open db file: $db_hold_name.\nReason: $!");
if ($db_use_flock) {
flock(DB, 2) or &cgierr("unable to get exclusive lock on $db_hold_name.\nReason: $!");
}
print DB $output;
close DB; # automatically removes file lock


# Build success/error messages.
foreach $key (keys Þlete_list) {
$delete_list{$key} ? # Check to see if any items weren't deleted
($errstr .= "$key,") : # that should have been.
($succstr .= "$key,"); # For logging, we'll remember the one's we deleted.
}
chop($succstr); # Remove trailing delimeter
chop($errstr); # Remove trailing delimeter

*****wrong*****
# Before we display the HTML, let's fire off some re-enter/delete emails
# NOTE: You can modify the text of the email in the email templates.
&html_print_headers; # Just in case sendmail coughs up an error.
ID: foreach $id (keys %hold_list) {
if ($hold_list{$id}) { next ID; }
elsif (!$in{"reason-$id"}) { next ID; }
elsif (${$links{$id}}{'Contact Email'} =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
${$links{$id}}{'Contact Email'} !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) {
$errstr .= ($errstr, "<li>Email Error: <strong>$id</strong>. Record deleted, but couldn't send rejection letter. Reason: Bad Email addres: '${$links{$id}}{'Contact Email'}'.");
}
else { &html_reject_email (%{$links{$id}});
}
*********wrong********

# Now let's go to the error page or the success page depending on
# what $errstr is.
$errstr ?
&html_generic ("Re-enter or Deleting Links", "Error Deleting links: <ul>$errstr</ul>") :
&html_holdval_success($succstr);
}
}

Thanks all for your help...

Quote Reply
Re: Sending Email Problem In reply to
The only thing I can of is that you have renamed the Contact Email field in your links.def file.

Regards,

Eliot Lee
Quote Reply
Re: Sending Email Problem In reply to
No I didn't. I will show you my:
admin.pl:
elsif ($in{'holdval_delete_records'}) { &holdval_delete_records; } # Delete a Hold record

admin_html.pl:
sub html_holdval_form {
# --------------------------------------------------------
# This page produces a list of records waiting to be validated,
# from which the admin can either delete, or validate the records.

# First let's just get a list of all the records to validate/modify.
my (@lines, @holdhits, $numhits, $counter);

# Go through each validated hit and convert the array to hash and send to
# html_record for printing. Also add a checkbox with name=key and value=delete.
for ($i = 0; $i < ($#holdhits+1) / ($#db_cols+1); $i++) {
last if (++$counter > 50);
%tmp = &array_to_hash ($i, @holdhits);
print qq|
<table border=1><TR><TD colspan=2>|;
&html_record_form_mult (%tmp);
my $reason = &load_template ('email-del.txt', \%tmp);
my $hold = &load_template ('email-hold.txt', \%tmp); print qq|
</TD></TR>
<TR><TD VALIGN=TOP><INPUT TYPE="RADIO" NAME="$tmp{$db_key}" VALUE="delete"> <$font>Delete. Email Reason:</font>
<textarea name="reason-$tmp{$db_key}" rows=4 cols=40>$reason</textarea></TD>
<TD VALIGN=TOP ROWSPAN=2><INPUT TYPE="RADIO" NAME="$tmp{$db_key}" VALUE="reenter"> <$font>Re-Enter. Email Reason:</font>
<textarea name="hold-$tmp{$db_key}" rows=4 cols=40>$hold</textarea></TD></TR>
<TR><TD VALIGN=TOP><$font><a href="$db_script_url?view_records=1&$db_cols[$db_url]=$tmp{$db_cols[$db_url]}" target="_blank">Duplicate Check</a></font></TD></TR>
</TABLE>
<hr width=550 bgcolor="black" size=4 align=left>
|;
}

Links.cfg:
$db_hold_name = "$db_script_path/data/hold.db"; # PATH to holding database

# Database Definition: LINKS
# --------------------------------------------------------
# Definition of your database file.
Û_def = (
'Contact Name' => [6, 'alpha', 40, 75, 1, '', ''],
'Contact Email' => [7, 'alpha', 40, 75, 1, '', '.+@.+\..+'],
);

# Field Number of some important fields. The number is from Û_def above
# where the first field equals 0.
$db_contact_name = 6; $db_contact_email = 7;

Do you have an other suggestion what the could be???

Thanks Hacktor


Quote Reply
Re: Sending Email Problem In reply to
Someone and/or Eliot does have an other solution to solve this problem?

Thanks

Quote Reply
Re: Sending Email Problem In reply to
Nope...but may be Bmxer can shed some light since he wrote the Mod.

Regards,

Eliot Lee