Formmail.pl

From SonicWiki
Jump to: navigation, search

FormMail Version 1.9s-p4

Steps for getting Help:

  1. Read this page thoroughly.
  2. Post your question and any relevant information (details!) to the sonic.help.cgi newsgroup.

Form Configuration:

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

<form Method=POST Action="/cgi-bin/formmail.pl">
At the end of the form you will need to put the closing form tag.
</form>

Necessary Form Field:

Field: recipient

Description:

Who the form results will be mailed to. You should configure this option as a hidden form field with a value equal to your e-mail address.

login should be your login name at sonic.

Syntax:

<input type=hidden name="recipient" value="login@sonic.net"> 

Optional Form Fields:

alink_color background bgcolor email link_color env_report print_config realname redirect required return_link_url return_link_title sort subject text_color title vlink_color

Field: subject

Description: This sets the subject will appear in the e-mail that is sent to you after the form has been filled out. The default subject is: WWW Form Submission

Syntax: To choose what the subject is:

<input type=hidden name="subject" value="Your Subject">

To allow the user to choose a subject:

<input type=text name="subject">

Field: email

Description: Allows the user to specify their return e-mail address. This will be put into the From: line of your message header.

Syntax:

<input type=text name="email">


Field: realname

Description:

The realname form field for the user's real name. This will also be in the From: line of your message header.

Syntax:

<input type=text name="realname">

Field: redirect

Description: After the user fills out the form, you can redirect the user to a different URL. If you don't include this they will see the default response. Point this to a pre-made HTML page.

Syntax: To choose the URL they will end up at:

<input type=hidden name="redirect" value="http://your.address/to/file.html">

To allow them to specify a URL they wish to travel to once the form is filled out:

<input type=text name="redirect">

Field: required

Description: Require certain fields in your form to be filled in. Place all the field names that you want to be mandatory into this field.

Syntax: If you want to require that they fill in the email and phone fields in your form, so that you can reach them once you have received the mail, use a syntax like:

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


Field: env_report

Description: If you want to include Environment variables in the e-mail message you receive. This is a short list of valid environment variables that might be useful:

  • REMOTE_HOST The remote hostname of the user making the request.
  • REMOTE_ADDR Sends the IP address of the remote host making the request.
  • REMOTE_USER The authenticated username if server supports authentication and script is protected. This is not usually set.
  • REMOTE_IDENT The user making the request. This variable will only be set if NCSA IdentiyCheck flag is enabled, and the client machine supports the RFC 931 identification scheme (ident daemon). This is not usually set.
  • HTTP_USER_AGENT The browser

Syntax: Put the options you want into your form, separated by commas:

<input type=hidden name="env_report" value="REMOTE_HOST,HTTP_USER_AGENT">

Field: sort

Description: Choose the order in which the variables will appear in the e-mail you receive. You can sorted alphabetically or specify a set order. The default is the order in which the browser sends the information to the script.

If you specify a set order, include the phrase "order:" as the first part of your value for the sort field. Follow that with the field names you want to be listed in the e-mail message, separated by commas.

Syntax: To sort alphabetically:

<input type=hidden name="sort" value="alphabetic">

To sort by a set field order:

<input type=hidden name="sort" value="order:name1,name2,etc...">

Field: print_config

Description: Specify which of the config variables you want printed in the e-mail message you get. The default is none, because email, subject, etc... are included in the header of the message.

Enter config fields that you want in the value attribute of your input tag separated by commas.

Syntax: To print the email and subject fields in the body of the message, place the following form tag:

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

Field: title

Description: Specify the title and header for the resulting page if you do not specify a redirect URL.

Syntax: If you wanted a title of 'Form Results':

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

Field: return_link_url

Description: Specify a URL that will appear, as return_link_title, on the following report page. This field will not be used if you have the redirect field set. A good way to link back to your main page.

Syntax:

<input type=hidden name="return_link_url" value="http://www.sonic.net/~username/index.html">


Field: return_link_title

Description: This is the title that will be used to link the user back to the page you specify with return_link_url. The two fields will be shown on the resulting form page as:

<a href="return_link_url">return_link_title</a> 

Syntax:

<input type=hidden name="return_link_title" value="Back to Main Page">

Field: background

Description: This form field allow you to specify a background image that will appear if you do not have the redirect field set. This image will appear as the background to the form results page.

Syntax:

<input type=hidden name="background" value="http://www.sonic.net/~username/image.gif">

Field: bgcolor

Description: This form field allow you to specify a bgcolor for the form results page in much the way you specify a background image. This field should not be set if the redirect field is.

For a list of color values, see the colors page.

Syntax: For a background color of White:

<input type=hidden name="bgcolor" value="#FFFFFF">

Field: text_color

Description: This field works the same way as bgcolor, except that it changes the color of your text.

For a list of color values, see the colors page.

Syntax: For a text color of Black:

<input type=hidden name="text_color" value="#000000">

Field: link_color

Description:

Changes the color of links on the resulting page. Works the same way as text_color. Should not be defined if redirect is.

'For a list of color values, see the colors page.

Syntax: For a link color of Red:

<input type=hidden name="link_color" value="#FF0000">

Field: vlink_color

Description: Changes the color of visited links on the resulting page. Works exactly the same as link_color. Should not be set if redirect is.

For a list of color values, see the colors page.

Syntax: For a visited link color of Blue:

<input type=hidden name="vlink_color" value="#0000FF">

Field: alink_color

Description: Changes the color of active links on the resulting page. Works exactly the same as link_color. Should not be set if redirect is.

For a list of color values, see the colors page.

Syntax: For a visited link color of Blue:

<input type=hidden name="alink_color" value="#0000FF">

All Other Fields

All other form fields in your script or page will be mailed back to you. In addition, if you do not have the redirect set, they will be displayed on the default response page.