#!/usr/bin/perl -w use CGI qw(:standard); #-----------------------------------------------------------------------# # Name: Form Email # By: Greg Dykes # 10-11-98 # # This is FREEWARE, have fun with it! # # Directions: # ----------- # This is a very simple perl script for sending an email message to # a specific email address. To use just set up a an html form with the # method of http://url/cgi-bin/formemail.cgi # then just set up three input features with the names of uname, address, # and message. # # Word of caution, you mail will show up from the user you have your httpd # server running under. In most cases with newer versions of Apache, it # will show up as the User Nobody. To try and cut down on "funny" messages, # I included the catch of grabbing the users Ip address as a deterent. # You may want to say something to the effect of "Your ip address is being # logged." To try and stop any malicious use by a sender. # # Variables: # ---------- # Set the address variable to where you want the message sent to # be sure to to put a "\" in front of the "@" symbol in the address # like this: gdykes\@kent.edu $address = "greg\@geauga.kent.edu"; # This url is where your cgi program resides. put the full internet path to the# form you user fills out to mail from. # (ie http://kent.edu/~gdykes/emailform.html) $form_url = "http://www.geauga.kent.edu/greg/perl.html"; # Set this feature where you want the user to be sent to after # confirmation of message sent. $goto_url = "http://kent.edu/~gdykes"; # #-------------------------------------------------------------------------# # Send top of HTML form to user print < Email Message

Email Message

END_OF_START # Declare Common variable for message my $uname = param("uname"); my $message = param("message"); my $address = param("address"); # This sets so that you can see the ip address from sender my $ip_addr = $ENV{'REMOTE_ADDR'}; # This checks to make sure user has entered a name, email address, and a message # if all are there, it wil go ahead and mail letter. if ($uname eq "") { print "

Please Enter A Name!

"; print "

Click here to go back"; } elsif ($message eq "") { print "

You must enter a message to be sent.

"; print "

Click here to go back"; } elsif ($address eq "") { print "

Please enter your email address.

"; print "

Click here to go back"; } else { open EMAIL, "|mail greg\@geauga.kent.edu"; print EMAIL "Subject: Web Massage from $uname ($ip_addr)\n"; print EMAIL "Return Email Address: $address\n"; print EMAIL "----------------------------------------\n\n"; print EMAIL "$message\n\n"; print EMAIL "----------------------------------------\n"; close EMAIL; print "

Message Sent!

"; print "

Click here to go on!"; } # End of Script