FormMail Readme

Complete installation and configuration guide for FormMail - the universal WWW form to email gateway (v1.6)

Perl v1.6 Documentation

Table of Contents

Overview

FormMail is a universal WWW form to E-mail gateway. There is only one required form input tag which must be specified in order for this script to work with your existing forms. Other hidden configuration fields can also be used to enhance the operation of FormMail on your site.

Version 1.6 of FormMail contains:

  • Minor bug fixes and optimized code
  • More comments in the source
  • Form fields now sorted as they appear in the form by default
  • Beautified error pages
  • Two new configuration fields

Setting Up the FormMail Script

The FormMail.pl script does not have to be extensively configured in order to work. There are only two variables in the perl file which you will need to define along with changing the top line of your script to match the location of your Perl interpreter.

$mailprog

Variable $mailprog = '/usr/lib/sendmail';
Description This variable must define the location to your server's sendmail program. If this is incorrect, form results will not be mailed to you.
Common Values /usr/lib/sendmail
/usr/sbin/sendmail
/usr/bin/sendmail

@referers

Variable @referers = ('worldwidemart.com','206.31.72.203');
Description This array allows you to define the domains that you will allow forms to reside on and use your FormMail script. If a user tries to put a form on another server not in this list, they will receive an error message.
Security Note By placing worldwidemart.com in the @referers array, this also allows www.worldwidemart.com, ftp.worldwidemart.com, any other http address with worldwidemart.com in it and the IP address to access the script.

Form Configuration

The action of your form needs to point towards this script, and the method must be POST or GET in capital letters.

Required Form Fields

There is only one form field that you must have in your form for FormMail to work correctly:

recipient

This form field allows you to specify to whom you wish for your form results to be mailed.

<input type="hidden" name="recipient" value="[email protected]">

Optional Form Fields

Specify the subject that will appear in the e-mail. Default: "WWW Form Submission"

<input type="hidden" name="subject" value="Your Subject">
<!-- Or allow user to choose: -->
<input type="text" name="subject">

Allow the user to specify their return e-mail address. This will be put into the From: field of the message you receive.

<input type="text" name="email">

Allow the user to input their real name. This will also be put into the From: line of your message header.

<input type="text" name="realname">

Redirect the user to a different URL rather than having them see the default response page.

<input type="hidden" name="redirect" value="http://your.host.com/thanks.html">

Specify which fields must be filled in before the form can be successfully submitted.

<input type="hidden" name="required" value="email,phone,name">

Include environment variables in the e-mail message:

  • REMOTE_HOST - Hostname making the request
  • REMOTE_ADDR - IP address of the remote host
  • HTTP_USER_AGENT - Browser the client is using
<input type="hidden" name="env_report" value="REMOTE_HOST,HTTP_USER_AGENT">

Choose the order in which variables appear in the e-mail.

<!-- Alphabetical sorting: -->
<input type="hidden" name="sort" value="alphabetic">

<!-- Custom order: -->
<input type="hidden" name="sort" value="order:name,email,phone,message">

Specify which config variables to print in the e-mail body (email, subject, etc.).

<input type="hidden" name="print_config" value="email,subject">

Print all form fields in the return HTML, regardless of whether they were filled in.

<input type="hidden" name="print_blank_fields" value="1">

Specify the title and header that will appear on the resulting page (if no redirect URL).

<input type="hidden" name="title" value="Feedback Form Results">

Specify a URL to redirect users to if required fields are not filled in.

<input type="hidden" name="missing_fields_redirect" value="http://your.host.com/error.html">

Customize the appearance of the response page:

background Background image URL
bgcolor Background color (e.g., #FFFFFF)
text_color Text color
link_color Link color
vlink_color Visited link color
alink_color Active link color (v1.4+)

Possible Uses of This Script

  1. You want to have a form that will be mailed to you, but aren't sure how to write the CGI script for it.
  2. You are the webmaster of your site and want to allow users to use forms, but not to have their own cgi-bin directories (which can cause security risks).
  3. Want to have one script to parse all of your HTML forms and mail them to you.

Version History

Version Date Changes
1.0 06/11/95 Initial release
1.1 08/03/95 Security hole fixed (command execution); redirect option added
1.2 09/23/95 Special fields no longer printed to mail or screen
1.3 01/21/96 Added: env_report, bgcolor, background, colors, title, return_link, required fields; @referers security
1.4 01/23/96 Added: sort, alink_color; bug fixes; GET/POST support
1.5 02/05/96 Sorting fixed; print_config option added
1.6 05/02/97 Default sorting by form order; better parsing; HTTPS redirect fix; email validation; print_blank_fields; missing_fields_redirect

Complete Form Example

<form action="/cgi-bin/FormMail.pl" method="POST">
    <!-- Required -->
    <input type="hidden" name="recipient" value="[email protected]">

    <!-- Optional Configuration -->
    <input type="hidden" name="subject" value="Contact Form Submission">
    <input type="hidden" name="redirect" value="http://example.com/thanks.html">
    <input type="hidden" name="required" value="name,email,message">
    <input type="hidden" name="env_report" value="REMOTE_HOST,HTTP_USER_AGENT">
    <input type="hidden" name="sort" value="order:name,email,phone,message">

    <!-- Form Fields -->
    <p>
        <label>Name:</label><br>
        <input type="text" name="name" size="40">
    </p>
    <p>
        <label>Email:</label><br>
        <input type="text" name="email" size="40">
    </p>
    <p>
        <label>Phone:</label><br>
        <input type="text" name="phone" size="20">
    </p>
    <p>
        <label>Message:</label><br>
        <textarea name="message" rows="6" cols="40"></textarea>
    </p>
    <p>
        <input type="submit" value="Send Message">
        <input type="reset" value="Clear Form">
    </p>
</form>

Related Documentation

Guestbook Readme

Installation guide for the Guestbook script

WWWBoard Readme

Installation guide for the WWWBoard forum

All Readme Files

Browse all script documentation