###############################################################################
# #
# F O R W A R D R E C O R D #
# #
# Last modified: 22 Jun 2000 #
###############################################################################
###############################################################################
# #
# This mod will allow your users to mail the contents of a record to #
# themselves or someone else.
# #
# The mod requires that you have the "sendmail" program on your system. #
# #
###############################################################################
###############################################################################
# file: default.cfg #
# #
# somewhere in the authentication definitions #
# add the following #
###############################################################################
# Full path to sendmail on your system
$mailprog = "|/usr/lib/sendmail -t -oeq";
###############################################################################
#file: db.cgi #
# sub main #
# #
# within the other "elsif" statements #
# add the following #
###############################################################################
elsif ($in{'forward_email_form'}) { &html_forward_email_form; }
elsif ($in{'forward_email'}) { &forward_email; }
###############################################################################
#file: db.cgi #
# sub get_record #
# #
# Delete or comment out the following line:
###############################################################################
($restricted = 1) if ($auth_modify_own and !$per_admin);
###############################################################################
#file: db.cgi #
# new subroutine #
# sub forward_email #
###############################################################################
sub forward_email {
# --------------------------------------------------------
# This subroutine added foward record mod
#
unless ($in{'email'}) { $message = "You must fill in your email address
"; }
unless ($in{'email'} =~ /.+\@.+\..+/) { $message = "Your email address is not in the correct format.
"; }
unless ($in{'to_email'}) { $message = "You must fill in the recipient's email address
"; }
unless ($in{'to_email'} =~ /.+\@.+\..+/) { $message = "The recipient's email address is not in the correct format.
"; }
unless ($in{'subject'}) { $message .= "You must fill in a subject for your message.
"; }
unless ($in{'emailmessage'}) { $message .= "Your email message is empty.
"; }
if ($message) {
chomp($message);
&html_forward_email_form($message);
return;
}
open (MAIL, "$mailprog") || &cgierr("unable to open mail program");
print MAIL "To: $in{'to_email'}\n";
print MAIL "From: $in{'email'}\n";
print MAIL "Subject: $in{'subject'}\n\n";
print MAIL "-" x 75 . "\n\n";
print MAIL $in{'emailmessage'};
close (MAIL);
&html_forward_email_success;
}
###############################################################################
#file: html.pl #
# sub html_record #
# #
# Just after #
# my (%rec) = @_; #
# #
# Add #
###############################################################################
$rec{$db_key} =~ s/.B>//g;
###############################################################################
#file: html.pl #
# sub html_record #
# #
# Add this link somewhere in the subroutine, probably close to the end. #
###############################################################################
Send this record to a friend
###############################################################################
#file: html.pl #
# new subroutine #
# sub html_forward_email_form #
###############################################################################
sub html_forward_email_form {
#----------------------------------------------------------
my ($message) = $_[0];
$in{$db_key} =~ s/.B>//g;
%rec = &get_record($in{$db_key});
unless ($in{'email_message'}) {
foreach $col (@db_cols) {
$in{'email_message'} .= "$col: $rec{$col}\n";
}
}
&html_print_headers;
print qq|
| $html_title: Send an email | |
|
|; if ($message) { print qq|There was a problem: $message|; } print qq| <$font>Fill in your email address, the subject of your email and the message you wish to send to $rec{'Name'}. |; print qq| |; &html_footer; print qq| | |
| $html_title: Send an email | |
|; print qq|<$font>Your email message was sent.
| |