Affordable Web Hosting with Excellent Customer Support internet connection free month hosting

Extending Mailform's Capabilities with .FORM files

The mailform package included in netConsole is an elegant email interface that allows you to consistently receive the information you want from users.

One way to further extend Mailform's usefulness, however, is with .FORM files. A .FORM file is a simple configuration file which:

  • Obfuscates the email address of the recipient, making it impossible for spammers to pull your address from the HTML source of the webpage containing the form.
  • Formats the email message you receive with no need for sorting fields. Plain-text format makes editing the message format extremely easy.
  • Contains all pertinent mailform information such as recipient, subject line, success/failure URLs, and required fields in an easy-to-read format without requiring any <input type="hidden"> tags.

Writing a .FORM File

The following is an example of a .form file:
Sender: "@{realname}" <@{email}>
Recipient: "Your Name" 
Subject: Join the Monkey Club!
Success: http://www.yourdomainname.com/success.shtml
Failure: http://www.yourdomainname.com/formerror.shtml
Required: realname,email,Number of Monkeys
--
Below is your form submission from ${REMOTE_ADDR} at ${SERVER_DATE}

Name:			@{realname}
Email:		@{email}

@{realname} would like to order @{Number of Monkeys} monkeys for their zoo.

Comments:

@{Comments}
Everything in the .form file above "--" is used by Mailform to determine the recipient, required fields, etc. Everything below the "--" tells Mailform how to format the email message.

To include form element values, enclose the form field name whose value you wish to use within curly braces, preceded by the @ sign: @{form field name}

Let's look at each part of our example .FORM file:

Sender:
The values after this heading will appear in the "From:" field in the email message.
Recipient:
The email message will be sent to the address you specify here.
Subject:
This line determines the subject of the email message.
Success:
When the script is executed without errors, users should be redirected to this URL.
Failure:
If errors occur, or all required fields are not filled out, users should be redirected to this URL.
Required:
Any form fields the user MUST fill out should be listed here.
--
The two hyphens signal the start of the email message format. Everything below this separator will be included in body of the email sent to the recipient.
Two special codes are used in the body of the message:
${REMOTE_ADDR}
This code will include the domain name from which the form was submitted.
${SERVER_DATE}
This code will show the time at which the form was submitted.
That's all there is to writing a .FORM file! When completed, the file should be given the ".form" extension and uploaded to the web server where your form webpage resides.

Using Your .FORM File

In the <form> tag of your webpage, specify the ACTION and METHOD like so:

<form action="path/to/yourfilename.form" method="post">

Unlike the standard Mailform script, no hidden input values are required. All the necessary information is included in the .FORM file.

Things to Remember

If your .FORM file is not behaving correctly, you should follow these steps:
  1. Ensure Mailform is installed and running correctly on your account.
  2. Make sure you uploaded the .FORM file in ASCII format.
  3. Check the spelling of your field names in the .FORM file against the field names in your form webpage.