Form mailer instructions

What is a form mailer?

Imagine you want to organize an event that guests can sign up for online. Now wouldn't it be nice if you could configure all of the details that the guests need to provide, such as the name, the number of attendees and whether they are bringing anything along? The form mailer lets you easily create these types of forms without requiring any in-depth programming knowledge. We explain how in the following.

How do i get started?

To begin with, you should consider what information you want to send using the form.
First, create a simple form. Make sure that the "form action" points to /cgi-sys/FormMail.cgi.

<form action="/cgi-sys/FormMail.cgi" method="post">
<table>
    <tr>
        <td>Your e-mail-adress:</td>
        <td><input type="text" name="email" /></td>
    </tr>
    <tr>
        <td>Your name:</td>
        <td><input type="text" name="realname" /></td>
    </tr>
    <tr>
        <td>Comment:</td>
        <td><textarea cols="20" rows="5" name="comment" ></textarea></td>
    </tr>
    <tr>
        <td><input type="submit" name="submit" value="Submit form" /></td>
    </tr>
</table>
<div>
        <input type="hidden" name="recipient" value="This email address is being protected from spambots. You need JavaScript enabled to view it." />
        <input type="hidden" name="subject" value="Contact form" />
</div>
</form>

 

This form looks like this:

 

 

The e-mail that you receive might look like this:

 

FROM: Hans Muster <This email address is being protected from spambots. You need JavaScript enabled to view it.>
TO: Info <This email address is being protected from spambots. You need JavaScript enabled to view it.>
SUBJECT: Formular abschicken

recipient: This email address is being protected from spambots. You need JavaScript enabled to view it.
comment: Please send me additional informations about your services.

Basic parameters for the form mailer

Parameters on the website or in a file

You can create the parameters with the hidden fields, i.e. the fields that are invisible on the form, or you can create a configuration file. This is helpful, for example, if you do not want your e-mail address to be shown on the form.
To do this, create a "formmail" folder in your FTP directory and then a "conf" folder inside this folder. The folders must have exactly these names. Now create a file called "my_form", for example, in the folders. In your FTP client, you should then see something like this:

 

You can then use the following option to integrate this file into your form:

 

<input type="hidden" name="conf" value="mein_formular"/>

 

The file is row-based and has the following format:
[fieldname]:[value]
All characters, including spaces and tabs, can be used for the value.

This file could contain the following:

recipient:This email address is being protected from spambots. You need JavaScript enabled to view it.
subject:My subject
confirmation:0
sort:alphabetic

Which e-mail addresses do I want to send my form to?

You can only send the forms to e-mail addresses from domains that belong to your Hostpoint account. You can send forms directly to an e-mail address along with a copy or blind copy to other e-mail addresses. These addresses must also belong to your account.

Recipient e-mail address (To:)

 

Configuration in the form code:
<input type="hidden" name="recipient" value="This email address is being protected from spambots. You need JavaScript enabled to view it."/>

 

Configuration in config file:
recipient:This email address is being protected from spambots. You need JavaScript enabled to view it.

Carbon copy e-mail address (Cc:)

Configuration in the form code:
<input type="hidden" name="cc_mail" value="This email address is being protected from spambots. You need JavaScript enabled to view it."/>

 

Configuration in the config file:
cc_mail:This email address is being protected from spambots. You need JavaScript enabled to view it.

Blind copy e-mail address (Bcc:)

Configuration in the form code:
<input type="hidden" name="bcc_mail" value="This email address is being protected from spambots. You need JavaScript enabled to view it."/>

 

Configuration in the config file:

bcc_mail:This email address is being protected from spambots. You need JavaScript enabled to view it.

Multiple e-mail addresses can be separated using commas.

Other important e-mail settings

Confirmation e-mail

Unfortunately, this function had to be removed due to abuse by spammers.

Subject

You can pre-fill the subject or leave it as user-definable. If you want to leave it up to the user, make the field visible. Otherwise, leave it invisible.

Configuration in the form code:
<input type="text" name="subject"/>
User-defined subject line:
<input type="hidden" name="subject" value="My subject"/>

 

Configuration in the config file:
subject:My subject

Name of the person filling out the form

The e-mail address of the person filling out the form must be entered in the "email" field. It will then appear in the header of the e-mail.

Configuration in the form code:
<input type="text" name="realname" />

 

E-mail address of the person filling out the form

Set the e-mail address of the person filling out the form as the sender
The e-mail address of the person filling out the form must be entered in the "email" field. It will then appear in the header of the e-mail.
Configuration in the form code:
<input type="text" name="email" />

 

Provide e-mail address of the person filling out the form as text content; set own address as the sender

In the first scenario, the e-mail address of the person filling out the form is set as the sender of the e-mail. This can cause problems right away, such as if there are mistakes in the e-mail addresses. Technologies such as SPF sometimes also prevent the form owner from receiving the e-mail.
For this reason, we recommend the configuration:

Configuration in the form code:
<input type="text" name="email_text" />

 

Configuration in the config file:
email: This email address is being protected from spambots. You need JavaScript enabled to view it.

Set the "email" value to an existing e-mail address belonging to your hosting account. This ensures that you will always receive the e-mail. The e-mail address of the person filling out the form is then included as plain text content.

Charset

The default character set for the form mailer is ISO-8859-1. If your page uses a different character set, you must configure this in the form mailer so that the data contained in the e-mail is displayed correctly. Use the "charset" field for this.

<input type="hidden" name="charset" value="utf-8" />

 

Sorting fields in e-mails

You can sort the form fields either alphabetically or in a certain order. If you do not sort the fields, they will be displayed randomly and not in the same way that they are listed on your webpage. The only way to sort the e-mails in the order they appear on the webpage is by using the "sort" field.

Sorting in alphabetical order

Configuration ib the form code:
<input type="hidden" name="sort" value="alphabetic"/>
Configuration in the config file:
sort:alphabetic

Sorting individually

In the e-mail, first the order and then the name are shown. If there are other fields, these are included below.

Configuration in the form code:
<input type="hidden" name="sort" value="order,Name"/>

 

Configuration in the config file:
sort:order,Name

Success and error pages

You can create a separate page that appears automatically when a form has been submitted successfully or when an error occurs.

The error page shows the problematic fields as GET parameters, which you can then read with a programming language.

Success page

Configuration in the form code:
<input type="hidden" name="redirect" value="http://www.your-own-domain.ch/success.html"/>
Configuration in the config file:
redirect:http://www.your-own-domain.ch/success.html

 

Error page

Configuration in the form code:
<input type="hidden" name="missing_fields_redirect" value="http://www.your-own-domain.ch/error.html"/>
Configuration in the config file:
missing_fields_redirect:http://www.your-own-domain.ch/error.html

Advanced parameters for the form mailer

You are, of course, free to make further configurations to your form.

The visitor can attach a file to the form

The visitor can send you files. This requires you to first configure the form to support files. Add the option enctype="multipart/form-data":

<form action="/cgi-sys/FormMail.cgi" method="post" enctype="multipart/form-data">

 

Each field that supports file attachments must begin with "file_" and be of the type "File".

 

<input type="file" name="file_anhang" />

 

IP address or browser information

You can also collect what are known as environment variables, i.e. information about the visitor's environment. Examples include the IP address, the name of the browser and the hostname of the visitor's computer.

Environment variables

REMOTE_HOST
Returns the hostname of the visitor's computer 
REMOTE_ADDR
Returns the visitor's IP address. 
HTTP_USER_AGENT
Returns the name of the user's browser and operating system. 
Configuration in the form code:
<input type="hidden" name="env_report" value="REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT" />
Configuration in the config file:
env_report:REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT

What should appear in the e-mail?

By default, all e-mail fields are sent. You can hide certain fields, however.

Hide fields

Here, "redirect", "sort", "missing_field_redirect" and "bcc_mail" are not shown in the e-mail:

Configuration in the form code:
<input type="hidden" name="print_config" value="redirect,sort,missing_field_redirect,bcc_mail" />
Configuration in the config file:
print_config:redirect,sort,missing_field_redirect,bcc_mail

Checking form input

You can easily check forms for the presence of variables or check them using a regular expression.

Required fields

You can choose this setting, for example, when completing the address fields of a form is mandatory.
Configuration in the form code:

<input type="hidden" name="required" value="name,firstname,street,postcode,city" />
Configuration in the config file:
required:name,firstname,street,postcode,city

Checking with a regular expression

You can add a regular expression with `[feld]_regex`. Note: To use this option, you must be familiar with regular expressions!

Configuration i the form code:
<input type="hidden" name="plz_regex" value="^\d+$" />
Configuration in the config file:
plz_regex:^\d+$

Logging

You can also have the messages that are sent to you saved in a file. The log is saved in the formmail/log folder in the same directory where "public_html" or "www" are located. The logfile parameter lets you select the particular log file.

 

You then define the file as the log file as shown here:

Logfile

Configuration in the form code:
<input type="hidden" name="logfile" value="mails.txt" />
Configuration in the config file:
logfile:mails.txt

Templates

You can customize the appearance of the e-mails you receive.

Creating templates

You can configure exactly how the e-mails you receive will be displayed.
To do this, create a file in the 
 formmail/templates folder located in the root FTP directory. You can name the file however you like. Let's name the template "anmeldung.txt".

You can then enter the e-mail display parameters in this file. The names in brackets here are placeholders for the actual field content.

Example

The content of the registration.txt file might look something like this:

Last name: [name]
First name: [vorname]
Street address: [strasse] [hausnummer]
ZIP/cityOrt: [PLZ] [ort]

Comment:
[kommentar]

An e-mail sent with the customer's data might therefore looke like this:
Last name: Doe
First name: John
Street address: Sample Street 1
ZIP/city: 1234 Sample city

Comment:
I'm coming with my wife and bring a cake.

Using templates

You can now use any template for e-mails that are sent to you.

Template for the e-mail you will receive

Configuration in the form code:
<input type="hidden" name="mail_template" value="anmeldung.txt" />
Configuration in the config file:
mail_template:anmeldung.txt

Layout of the success and error pages

You can make some changes to the layout of the success and error pages even without a separate HTML page. These options are only relevant if you do not create your own success or error page.

Background

Background image for success and error pages

Configuration in the form code:
<input type="hidden" name="background" name="http://your-own-domain.ch/background.png" />
Configuration in the config file:
background:http://your-own-domain.ch/background.png

Background color of the success and error pages

Configuration in the form code:
<input type="hidden" name="bgcolor" name="gray" />

 

Configuration in the config file:
bgcolor:gray

Background image for the success page

Configuration in the form code:
<input type="hidden" name="success_background" name="http://your-own-domain.ch/background.png" />
Configuration in the config file:
success_background:http://your-own-domain.ch/background.png

Background color of success page

Configuration in the form code:
<input type="hidden" name="success_bgcolor" name="gray" />
Configuration in the config file:
success_bgcolor:gray

Background image for error page

Configuration in the form code:
<input type="hidden" name="error_background" name="http://your-own-domain.ch/background.png" />
Configuration in the config file:
error_background:http://your-own-domain.ch/background.png

Background color for error page

Configuration in the form code:
<input type="hidden" name="error_bgcolor" name="gray" />
Configuration in the config file:
error_bgcolor:gray

Title

The title for the success and error page can be set as follows:

Title of success page

Configuration in the form code:
<input type="hidden" name="success_title" name="Mail sent" />
Configuration in the config file:
success_title:Mail sent

Title of error page

Configuration in the form code:
<input type="hidden" name="error_title" name="Fields incorrect" />
Configuration in the config file:
error_title:Fields incorrect
Configuration in the form code:
<input type="hidden" name="error_key_color" name="blue" />
Configuration in the config file:
error_key_color:blue

Background color for error page

Configuration in the form code:
<input type="hidden" name="error_value_color" name="red" />
Configuration in the config file:
error_value_color:red

Examples

How a form might look

Formular für eine Partyanmeldung

 

The Code looks like this:
<form action="/cgi-sys/FormMail.cgi" method="post">
<table>
<tr>
<td>Ihr Name:</td>
<td><input type="text" name="realname" /></td>
</tr>
<tr>
<td>Transport (f&uuml;r die Parkplatzorganisation):</td>
<td>
<input type="radio" name="transport" value="OEV" />
&Ouml;V
<input type="radio" name="transport" value="Auto" />
Auto
</td>
</tr>
<tr>
<td>Anzahl Personen:</td>
<td><input type="text" name="personen" size="2"/></td>
</tr>
<tr>
<td valign="top">Wir bringen folgendes mit:</td>
<td><textarea name="mitbringen" rows="5" cols="22"></textarea>
</td>
</tr>
<tr>
<td><input type="submit" name="submit" value="anmelden" /></td>
</tr>
</table>
<div>
<input type="hidden" name="print_config" value="subject,recipient,submit" />
<input type="hidden" name="recipient" value="This email address is being protected from spambots. You need JavaScript enabled to view it." />
<input type="hidden" name="subject" value="Anmeldung fuers Fest" />
</div>
</form>

The e-mail that you receive might then look like this:

mitbringen: Rüblikuchen
personen: 5
realname: Hans Muster
transport: Auto

Form with checking

You want to create a form for a course registration and check the variables.

 

On this form, the last name, first name as well as a course and level must be specified. The age must consist of exactly two numbers. The code looks like this:

 

<form action="/cgi-sys/FormMail.cgi" method="post">
<table>
<tr>
<td>Ihr Name:</td>
<td><input type="text" name="realname" /></td>
</tr>
<tr>
<td>Ihr Vorname:</td>
<td><input type="text" name="vorname" /></td>
</tr>
<tr>
<td>Alter:</td>
<td><input type="text" name="alter" size="2" /></td>
</tr>
<tr>
<td>Kurs:</td>
<td>
<select name="kurs">
<option value="Java">Java</option>
<option value="C_plus_plus">C++</option>
<option value="PHP">PHP</option>
<option value="ASP">ASP</option>
</select>
</td>
</tr>
<tr>
<td valign="top">Schwierigkeitsgrad:</td>
<td>
<input type="radio" name="level" value="Anfaenger" />
anf&auml;nger &nbsp;
<input type="radio" name="level" value="Fortgeschrittene" />
fortgeschrittene &nbsp;</td>
</tr>
<tr>
<td><input type="submit" name="submit" value="anmelden" /></td>
</tr>
</table>
<div>
<input type="hidden" name="print_config" value="subject,recipient,submit,alter_regex,required" />
<input type="hidden" name="recipient" value="This email address is being protected from spambots. You need JavaScript enabled to view it." />
<input type="hidden" name="subject" value="Anmelden" />
<input type="hidden" name="required" value="realname,vorname,kurs,level" />
<input type="hidden" name="alter_regex" value="^\d{2}$" />
</div>
</form>

 

 

Unable to find what you were looking for?

Our support experts are happy to assist you personally!

 

© 2001 - Hostpoint AG