#!/usr/bin/perl $active = 1; # Logging flag. Logs on POST method when mail is sent. $logging = 0; $logfile = ''; # physical location of your cgi-lib.pl $cgi_lib = 'cgi-lib.pl'; # path to sendmail and its flags $sendmail = "/usr/lib/sendmail -t"; ############################# # end of configurable options ############################# require $cgi_lib; &ReadParse(); ######################################### # take the POSTed information and mail it ######################################### if ($ENV{'REQUEST_METHOD'} eq 'POST') { # From: comes from $in{'from'} # To: comes from $in{'to'} # Cc: comes from $in{'cc'} # Subject: comes from $in{'sub'} # body comes from $in{'body'} $fromaddr = $in{'from'}; $destaddr = $in{'to'}; $cc = $in{'cc'}; $subject = $in{'sub'}; $bodyin = $in{'body'}; $marker = $in{'mark'}; $majordomo = $in{'domo'}; $replytoin = $in{'replyto'}; $fromname = $in{'name'}; $nexturl = $in{'nexturl'}; # Determine where Mailing Errors should go. if ($ENV{'REMOTE_HOST'}) { $errorsto = $ENV{'REMOTE_IDENT'} ? "$ENV{'REMOTE_IDENT'}\@$ENV{'REMOTE_HOST'}" : "root\@$ENV{'REMOTE_HOST'}"; $realfrom = $ENV{'REMOTE_HOST'}; } else { $errorsto = "webmaster\@chinavista.com"; $realfrom = $ENV{'REMOTE_ADDR'}; } # If the form is being used to subscribe to a majordomo list. if ($majordomo) { $body = join(" ",$bodyin,$fromaddr); $replyto = "nobody\@chinavista.com"; # discard majordomo replies. } else { $body = $bodyin; if ($replytoin) { $replyto = $replytoin; } else { $replyto = $fromaddr; } } # Convert multiple bodies (separated by \0 according to CGI spec) into one. $body =~ s/\0//; # Check to see if required inputs were filled unless ($destaddr && $fromaddr && ($fromaddr =~ /^.+\@.+/)) { print &PrintHeader(); print <Forms-Email Error

Email Error

You need to fill in Your Email Address correctly to send email.


Back to the Previous Page EOH exit(0); } # Some quick logging. if ($logging) { open(MAILLOG,">>$logfile"); print MAILLOG "$realfrom\n"; close(MAILLOG); } # Log every CGI variable except for the ones reserved for mail info. # Valid vars go into @data. Text output goes into $data and gets. # appended to the end of the mail. # First, get an ORDERED list of all cgi vars from @in to @keys for (0 .. $#in) { local($key) = split(/=/,$in[$_],2); $key =~ s/\+/ /g; $key =~ s/%(..)/pack("c",hex($1))/ge; push(@keys,$key); } # Now weed out the ones we want @reserved = ('to', 'cc', 'from', 'name', 'sub', 'body', 'replyto', 'domo', 'mark', 'nexturl'); local(%mark); foreach (@reserved) { $mark{$_} = 1; } @data = grep(!$mark{$_}, @keys); foreach (@data) { $data .= "$_ -> $in{$_}\n"; } # Fork over the mail to sendmail and be done with it if ($active) { open(MAIL,"| $sendmail") || die "Can't exec $sendmail: $!\n"; # only print Cc if we got one print MAIL "Cc: $cc\n" if $cc; print MAIL <Forms-Email Results

Email Sent

Thank you for sending mail to $destaddr.

Subject: $subject
From: $fromaddr

$body

Back to the Previous Page EOH ; } exit(0); } ##################################### # What the heck are we doing here???? ##################################### else { print &PrintHeader(); print <Forms-Email Error

Error

Somehow your browser generated a non POST/GET request method and it got here. You should get this fixed!!

EOH } exit(1);