Form2Mail v1.8

Download and install

If your server is Windows 95/98/NT/2000:
  1. Requirements:
    • You need to know the hostname of an SMTP server, and this SMTP server must be configured to accept email from you.
  2. Download Form2Mail-1.8.zip (69Kb)
  3. Unpack the zip-file into the homedirectory of your webserver, for example “c:/inetpub/”. The intention is to make everything in the zip-file available as “/Form2Mail/*” and “/scripts/Form2Mail.exe” to the rest of the internet. Make sure the “c:/inetpub/scripts/” folder has “Scripts and Executables” permissions.
  4. Follow the directions below in the “Using Form2Mail” section.

If your server is Unix (Linux and others):

  1. Requirements:
    • A certain minimal Unix knowledge is required. If you have never logged on with Telnet and used the Unix commandline, then it’s unlikely you can install the program. Don’t try to use the Windows version, it simply won’t work.
    • You must have full cgi-bin capability on your server. Some providers do not allow the use of cgi-bin programs, or only permit the use of scripts (PHP, PERL, etc.). Form2Mail is a binary program, not a script.
    • You must have access to the C compiler on the server.
    • You must know the location of the sendmail program on the server.
  2.  Download Form2Mail-1.8.tar.gz (45Kb)
  3. Unpack the tar-file. There is a “html” directory and a “sources” directory. Copy the “html” directory to the document tree of your webserver. The intention is to make everything available to the rest of the internet, for example “/Form2Mail/Basic/Form.html”.
  4. Go into the sources directory and enter “make” (no parameters). This command will start the C-compiler. There is no need to configure anything at this stage, the program will take all it’s settings from the configuration file at run-time. If “make” completed without errors then copy the just-created “Form2Mail.cgi” program to your cgi-bin directory.
  5. Follow the directions below in the “Using Form2Mail” section.

Frequently asked questions

You’ll have to ask your provider. The operating system of your desktop is not relevant.

  • Can I use the Windows version on a Unix server?

No. Unix is completely different, you absolutely must compile the program to use it on a Unix server.

  • How do I execute “make”? (Unix)

Use a Telnet program to login to the Unix server and enter “make” on the commandline. If you have never worked with a Unix commandline before then it is unlikely you can install the Form2Mail program.

Using Form2Mail

Select a sample configuration

The distribution contains 4 sample configurations in the “html/Form2Mail/” directory. Select one of these configurations as your starting point:

Basic
A flexible starting point for a basic email-form.
Expert
The same as Basic but with more elaborate html.
Mime
The same as Basic but for MIME encoded email.
X-html
The same as Basic but for X-html encoded email.

Customize the sample configuration

Every sample configuration contains these 5 files:

Form2Mail.cfg
The configuration file. Form2Mail will take all it’s settings from this file. Copy it to the same directory as the Form2Mail program, the cgi-bin directory. The contents of this file is explained in detail below, but for now just open it in a text-editor. Make a smart guess as to what the fields should contain and change them accordingly.
Form.html
The form for your users. Open the file with a text editor and find the email address “root@foobar.com”. Change it into your own email address. If you have taken the Expert configuration then look for this email address in the configuration file instead and change it there.
Mail.txt
The email that will be sent. No need to change anything at this time, but take a look anyway. Notice the fields such as “<%macro Message%>”? They will be replaced by values from the form.
Result.html
The page that will be displayed after the email has been sent. You can customise this file later to show anything you want, as with all files of Form2Mail, but let it be for now.
Error.html
The page that will be displayed when something is amiss. No need to change anything now.

Try the program. Open the “Form.html” in your browser, enter stuff, and check if the email is beïng sent. If all is well you can start customizing the templates.

Adding a datafield

There are two places where you should add a datafield: in the form and in the email. Suppose you want to add a field for the surname of the visitor. Add the following lines to the “Form.html” and the “Mail.txt” files:

Form.html
<input type=text name=”SurName”>
Mail.txt
<%macro SurName%>

The Form2Mail program will receive the “Surname” field from the form, and will replace the “SurName” macro in the email with whatever the user has entered. You can use any name for the field you like. The “Result.html” and “Error.html” templates also support the macro’s. See the “Expert” configuration for examples how you can use radio-butons, checkboxes, select’s, and textarea’s.

 

Parameters

The Form2Mail program is very flexible in accepting parameters. You can specify parameters in the form or in the configuration file.

Form and/or configuration file

You can specify the following parameters in the configuration file or as hidden fields in the form. Parameters in the configuration file will override same parameters in the form.

To The email address to which the email will be sent. If this parameter is not present in the configuration file then it will be taken from the form. For example: Configuration: To=”root@foobar.com”
Form: <input type=hidden name=To value=”root@foobar.com”>
From The email address from which the email will be sent. This is for the benefit of the receiver of the email, a reply will go to this email address. If this parameter is not present in the configuration file then it will be taken from the form. For example: Configuration: From=”root@foobar.com”
Form: <input type=hidden name=From value=”root@foobar.com”>
Mail The filename of the template used for the outgoïng email. The filename may not contain the directory characters “/” or “” (see the “Root” parameter). For example:Configuration: Mail=”mail.txt”
Form: <input type=hidden name=Mail value=”mail.txt”>In the top of the Mail template you can specify any email headers you like, separated from the body of the email by an empty line. Fields in the form are available as macros’, for example:<%macro name%>

Tip: Send an email to yourself with a normal email program. Use the received email as an example for the Mail template. Result  The filename of the html-page that is displayed after an email has been succesfully sent. The filename may not contain the directory characters “/” or “” (see the “Root” parameter). For example:Configuration: Result=”result.html”
Form: <input type=hidden name=Result value=”result.html”> You can use macro’s in the same way as in the Mail template to fetch values from the form. Error The filename of the html-page that is displayed when an error occurs. The filename may not contain the directory characters “/” or “” (see the “Root” parameter). For example:Configuration: Error=”error.html”
Form: <input type=hidden name=Error value=”error.html”> You can use macro’s in the same way as in the Mail template to fetch values from the form. A special macro “ErrorMessage” will contain a short explanation of the error.

Form only

You can specify the following parameters as hidden fields in the form.

Cfg  The configuration to be used. If not specified then the “default” configuration will be used. The contents must refer to a configuration-section in the configuration file, and be exactly the same as the text between “[” and “]”. For example: <input type=hidden name=Cfg value=”Example1″>

Configuration file only

The following parameters can only be set in the configuration file.

Root The root directory where the templates are stored. You can specify a different root directory per email-configuration. For example: Root=”d:/www/Form2Mail/Templates/”
Smtp The domain name of the SMTP server to use for sending the email. On Windows 95/98/NT/2000 this is a required parameter, on Unix you can alternatively specify the Sendmail setting. You can specify a different Smtp server per email-configuration. For example: Smtp=”mail.foobar.com”
Sendmail  Unix only The location of the sendmail program. It is only used if there is no “Smtp” setting present. You can specify a different Sendmail program per email-configuration. For example: Sendmail=”/usr/lib/sendmail”