over 80% of the code would be the same, but you need to use a form to get the user's email address and have a hidden field called 'action' with a value of 'send'.
I suggest you go ahead and use the test version of 1.0 since it's almost the 'exact' same code as 2.0, and it's easier for me to make changes and adapt it quicker for both versions.
Code:
sub send {
my ($email, @links, $links, $msg, $mailer);
$email = param('email');
$email =~ /^.+\@.+\..+$/ or &error('invalid looking email address');
if ($old) {
my @saved = split /\|/, $old;
open (DB, "$db_lib_path/data/links.db") or &error("Could not open file links.db. $!");
while (<DB>) {
chomp(my $line = $_);
foreach my $id (@saved) {
$line =~ /^$id\|/ or next;
my @rec = split /\|/, $line;
push @links, [ @rec ];
}
}
close (DB);
}
if ($#links > -1) {
foreach (@links) {
my %rec = array_to_hash(0, @{$_});
$links .= &load_template('portal_link_mail.html', { %rec, %globals });
}
} else { $links .= 'You have not saved any favorites.'; }
$msg = qq|Below is listing of all your saved links:\n|;
$msg .= qq|\n$links\n|;
$msg .= qq|To view your favorite links online, visit:\n|;
$msg .= qq|$db_cgi_url/portal.cgi|;
require "$db_lib_path/Mailer.pm";
$mailer = new Mailer ({
'smtp' => $db_smtp_server,
'sendmail' => $db_mail_path,
'from' => $db_admin_email,
'subject' => 'Your saved links',
'to' => $email,
'msg' => $msg,
'log' => ''
}) or return;
$mailer->send or return;
print header();
print &load_template('portal_mail.html', { %globals });
}
Note, I've updated the other post as well, because I noticed a few syntax errors.
--Drew
Free, hot camel soup for Links hackers...
http://www.camelsoup.com