Tech Support Topics

Sphynx Server CGI

FormMail - Form Handling Script Configurable at Runtime

formmail-z.pl


  1. Installation
  2. Automated Reply
  3. About the Author


Installation

To install this full-featured version of formmail, you will need to install the formmail-z.pl script in your cgi-bin directory, then make the script executable. There is really no need to hack this script as most variables can be set from your html form page at runtime.

  1. This script is not archived on your server's host machine. Open the formmail-z.pl script with your browser and "save-as" a text or source file (in this case the same thing) to your local computer. Using a text editor, you will set a couple of configuration lines on the script to prevent people from all over the web from using your script (and your server processor time) for their pages. Here's the portion of formmail-z.pl you will need to edit:
    ##############################################################################
    # Define Variables 
    #        Detailed Information Found In README File.
    
         Below, enter the location of sendmail on your 
         server. If you have not changed the configuration 
         or directory structure, the line below will be
         $mailprog = '/bin/sendmail';
    # $mailprog defines the location of your sendmail program on your unix 
    # system.
    
    $mailprog = '/usr/lib/sendmail';
    
          Below, enter all possible domain names for your 
          virtual server, which would be your IP address, 
          www.your-domain.com, and your-domain.com. (in 
          place of worldwidemart.com)
    # @referers allows forms to be located only on servers which are defined 
    # in this field.  This fixes a security hole in the last version which 
    # allowed anyone on any server to use your FormMail script.
    
    @referers = ('www.worldwidemart.com','worldwidemart.com','206.31.72.203');
    
    # Done
    #############################################################################
    
    
    

  2. Next, using ftp, upload the script to your cgi-bin directory, ~/www/cgi-bin. After the edited script has been uploaded, open a telnet session with your server and type the following at the shell prompt to make formmail-z.pl executable:
      % chmod 755 ~/www/cgi-bin/formmail-z.pl
    
    

  3. Now, just create an online order form, send-comments form or get-info form and follow the same instructions give to Sphynx Site customers for using formmail-z.pl on sphynx.com. Or read the documentation that comes with the FormMail archive. Only one field must be included in the form, the "recipient" field.

    Example HTML source for an online form:

      <form method="POST" action="/cgi-bin/formmail-z.pl">
      <input type="hidden" name="recipient" value="get-info@yourdomain.com">
      <input type="hidden" name="subject" value="Send Me Info">
      Please Enter Your Name:<br>
      <input name="realname" size="40">
      <p>
      Enter Your Email Address:<br>
      <input name="username" size="40">
      <p>
      Enter your location:<br>
      <input name="hometown" size="40">
      <p>
      .
      .
      .
      <input type="submit" value="Submit">
      <input type="reset" value="Reset">
      </form>
    


Automated Reply

As with simple formmail, one way to modify the script is to include an autoresponder that emails the user a response after he or she submits the form. To do this append something like the following to the bottom of the formmail-z.pl script.
  # open a message to the remote client
  open (MAIL, "|$mailprog $FORM{'username'}") || die "Can't open $mailprog!\n";
  print MAIL "To: $FORM{'username'} ($FORM{'realname'})\n";
  print MAIL "Reply-To: $FORM{'recipient'}\n";
  print MAIL "From: $FORM{'recipient'}\n";
  print MAIL "Subject: $FORM{'subject'}\n\n";

  # write out a customized response to the mail message 
  print MAIL "We have received your message and are delighted";
  print MAIL "you have requested information about our products.";
  print MAIL "Here is the information you requested - ";
  print MAIL "Product 1. - info about product 1";
  print MAIL "Product 2. - info about product 2";
  print MAIL "Product 3. - info about product 3";
  print MAIL "Product 4. - info about product 4";
  print MAIL "Product 5. - info about product 5";
  print MAIL "Yours truly, John Doe, sales rep.";

  # close the message
  close (MAIL);

Please Note: If you do use an autoresponder addition to the script, then the resulting script will be useable only by the form page owner who wants to reply with this particular autoreply.
One possible solution to this problem is to use one formmail-z.pl script without autoreply for everyone on your server to submit their forms to, and other versions of the script preconfigured with certain autoreplies. The secret is to name each different copy of the script differently (formmail-z.pl, formmail-z1.pl, formmail-z2.pl, etc.) and upload each to your cgi-bin and then make them executable with chmod.


FormMail's Author

FormMail was written by and continues to be developed by Matt Wright. For more information or for an excellent source of Perl scripts, see
Matt's Script Archive.


HOME | SITE HOSTING | VIRTUAL SERVERS | PAGE DESIGN | FAQ | ORDER | TECH SUPPORT


Copyright © 1996, Sphynx Web Solutions. All rights reserved. All brand names and product names used on these web pages are trademarks, or trade names of their respective holders. Direct questions or comments to webmaster@sphynx.com.