CGI: mail_answer.pl
Introduction
This CGI is used to format nicely and e-mail the content
of an HTML form.
Quick setup
Create an HTML form with the "METHOD" POST and the "ACTION"
/cgi-bin/mail_answer.pl.
Name each fields of your form by a number, followed by a ".", followed
by the name of the field. When the form is submited, you will receive
a mail containing the name of each field, followed by its content.
The fields will be printed in the order of their number.
Example : 01.Name or 02.Address
Finaly, your form must contain the following fields with pre-defined
values :
| Field name | Field value |
| F_subject | Subject of the mail |
| F_mailto | Address e-mail where to send the mail |
| F_answer | URL of the page to display after the form is submited |
Full example
My form
A simple form
Details
This script take the value from an HTML form page and use those values
to format a mail. The mail is then sent to an address.
The following hidden field must be defined in the HTML form :
F_mailto = E-mail address to which the mail should be sent
The following field may (or not) be defined in the HTML form :
F_header = Name of a text file to add at the begining of the mail
F_footer = Name of a text file to add at the end of the mail
F_answer = Name of an HTML page to display as result of this script
F_subject = Subject of the mail
Other field need to be one of the following format :
1) $\S+ (a dollard sign followed by any characters)
2) \d+[FLAG]*\..+ (Some digit followed by one or more FLAG characters
followed by a ".", followed by one or more chars.
The meaning of those value is the following :
[].
The formating flags should be one of more of the following :
T = don't print the Title
f = Force the value of the field on the same line as the title
b = force a line Break after the title
N = Don't print a Newline after the value
n = Force an extra Newline after the value
s = Field Separator. The next chars will be used to separate the
values
Field of type 1) are variable. If the same name appears in the answer
HTML form (including the "$"), it will be substitued by the value of the
field.
Field of type 2) will be printed, in order of there in the
mail. The value of the field is formated based on the
value.
The default is to print the followed by the value of the
field on the same line if the length of the whole line isn't larger than
80 chars. If it's larger, the value will be displayed alone one a new
line.
Each couple of title/value is put on a new line.
Example :
1) Fields name : 01.Name Value : Stettler
02.Forname Value : Yann
03.Address Value : Gide 6
04.Comments Value : Hello world
Will give a mail that look like :
Name : Stettler
Forname : Yann
Address : Gide 6
Comments : Hello world
2) Fields name : 01N.Name Value : Stettler
02T.Forname Value : Yann
03n.Address Value : Gide 6
04b.Comments Value : Hello world
Will give a mail that look like :
Name : Stettler Yann
Address : Gide 6
Comments :
Hello world
3) Fields name : 01TNs;.Name Value : Stettler
02TNs;.Forname Value : Yann
03TNs;.Address Value : Gide 6
04TNs;.Comments Value : Hello world
Will give a mail that look like :
Stettler;Yann;Gide 6;Hello world;