Thanks for the tips :)
How does this look:
#!/usr/bin/perl
#The path to the mail program on your system
$mailprog = "/usr/sbin/sendmail";
# redirect page
$redirect = "http://";
# Site url being referred
$siteurl = "http://";
# Read the form
read(STDIN, $input, $ENV{'CONTENT_LENGTH'});
# split the input
@pairs = split(/&/, $input);
# split the name/value pairs
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<([^>]|\n)*>//g;
$FORM{$name} = $value;
}
# some variables
$to = $FORM{'to'};
$tomail = $FORM{'tomail'};
$from = $FORM{'from'};
$frommail = $FORM{'frommail'};
$message = $FORM{'message'};
# make all first characters of names, uppercase
@from = split(/ /, $from);
@from = map ucfirst, @from;
@to = split(/ /, $to);
@to = map ucfirst, @to;
# make the first letter of the message upper case
$message = ucfirst($message);
##############################################
# puts a period at the end of senders message,
# if one was not there, AND, if there is no
# question OR explanation mark.
$message .= '.' if $message !~ /[.!?]$/;
# do the mail...
open (MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n";
print MAIL "From: $frommail\n";
print MAIL "To: $tomail\n";
print MAIL "Subject: @to, @from says check out $sitename!\n\n";
print MAIL "This is NOT spam! You were sent the email by @from ($fro
+mmail),\nat IP: $ENV{'REMOTE_ADDR'}\n\n\n";
print MAIL "Hello @to, @from has sent you this email inviting you to
+ check out $siteurl\n\n\n";
print MAIL "@from also had this to say:\n$message\n\n\n" if ($messag
+e ne "");
print MAIL "So check out $siteurl!";
close (MAIL);
# redirect the browser
print "Location: $redirect\n\n";
# tell me if they told
#&told;
exit;
sub told {
open (MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n";
print MAIL "To: toldafriend\@whatever.com\n";
print MAIL "From: toldafriend\@whatever.com\n";
print MAIL "Subject: $frommail (@from) told $tomail (@to)\n";
close(MAIL);
}
Do I need the exit; line about "sub told" ?? |