Thanks!
This works just like I wanted it to! However... :) I also want to use it for the Private Emailer Mod (a sendmail like mod within DB Man) and cant get it to work.
I thought I would be able to use the same code at top of sub send_email, but it just gets "ignored"...
sub send_email {
# --------------------------------------------------------
# This subroutine added for the private email mod
#
$descr = $in{'emailmessage'};
$descr =~ s/\s+/ /g;
$descr =~ /^\s+(.+)$/ ? ($descr = $1) : ($descr = $descr);
@words = split(/\s/,$descr);
foreach (@words) {
unless ($_ =~ /^\S{1,25}$/) {
push(@input_err, "$col <font face=arial,verdana,helvetica,sans serif size=2
color=ce0000><b>You have words that are too long in your description field.
You are not allowed to enter words that are longer than 25 characters in length. Check
your Description field and shorten any words that are to long.</b>");
last;
}
}
unless ($in{'email'}) { $message = ".<BR>"; }
unless ($in{'email'} =~ /.+\@.+\..+/) { $message = "Your email address is incorrect.<BR>"; }
unless ($in{'subject'}) { $message .= "You must fill in a subject for your message.<BR>"; }
unless ($in{'emailmessage'}) { $message .= "You must enter a message.<BR>"; }
%rec = &get_record($in{$db_key});
if (!%rec) { $message .= "The email address you requested could not be found.<BR>"; }
elsif (!$rec{$db_email_field}) { $message .= "There is no email address on file for this person.<BR>" }
if ($message) {
chomp($message);
&html_send_email_form($message);
return;
}
open (MAIL, "$mailprog") || &cgierr("unable to open mail program");
print MAIL "To: $rec{$db_email_field}\n";
print MAIL "From: $in{'email'}\n";
print MAIL "Subject: $in{'subject'}\n";
print MAIL "Content-Type: Text/Html\n\n";
print MAIL "<HTML><DIV>\n";
$in{'emailmessage'}=~s/\n/
/g;
print MAIL $in{'emailmessage'};
print MAIL "</DIV></HTML>";
close (MAIL);
&html_send_email_success;
}
This works just like I wanted it to! However... :) I also want to use it for the Private Emailer Mod (a sendmail like mod within DB Man) and cant get it to work.
I thought I would be able to use the same code at top of sub send_email, but it just gets "ignored"...
sub send_email {
# --------------------------------------------------------
# This subroutine added for the private email mod
#
$descr = $in{'emailmessage'};
$descr =~ s/\s+/ /g;
$descr =~ /^\s+(.+)$/ ? ($descr = $1) : ($descr = $descr);
@words = split(/\s/,$descr);
foreach (@words) {
unless ($_ =~ /^\S{1,25}$/) {
push(@input_err, "$col <font face=arial,verdana,helvetica,sans serif size=2
color=ce0000><b>You have words that are too long in your description field.
You are not allowed to enter words that are longer than 25 characters in length. Check
your Description field and shorten any words that are to long.</b>");
last;
}
}
unless ($in{'email'}) { $message = ".<BR>"; }
unless ($in{'email'} =~ /.+\@.+\..+/) { $message = "Your email address is incorrect.<BR>"; }
unless ($in{'subject'}) { $message .= "You must fill in a subject for your message.<BR>"; }
unless ($in{'emailmessage'}) { $message .= "You must enter a message.<BR>"; }
%rec = &get_record($in{$db_key});
if (!%rec) { $message .= "The email address you requested could not be found.<BR>"; }
elsif (!$rec{$db_email_field}) { $message .= "There is no email address on file for this person.<BR>" }
if ($message) {
chomp($message);
&html_send_email_form($message);
return;
}
open (MAIL, "$mailprog") || &cgierr("unable to open mail program");
print MAIL "To: $rec{$db_email_field}\n";
print MAIL "From: $in{'email'}\n";
print MAIL "Subject: $in{'subject'}\n";
print MAIL "Content-Type: Text/Html\n\n";
print MAIL "<HTML><DIV>\n";
$in{'emailmessage'}=~s/\n/
/g;
print MAIL $in{'emailmessage'};
print MAIL "</DIV></HTML>";
close (MAIL);
&html_send_email_success;
}