1and1 Help Centre Categories

print article

Example 4: Multiple Forms with Different Recipients

This example adds an additional form to the same site, this time asking people about their favorite plant. The results of this form get mailed to a new address,

<foo@your.domain>   

.

An extra line in the

%recipient_alias

part tells FormMail.pl how to handle a recipient value of "plants":

%recipient_alias   = (
'animals' => 'your-name@your.domain,your-name@somewhere-else.domain',
'plants' => 'foo@your.domain',
);

Putting all that together, the configuration section of the script is now:


# USER CONFIGURATION SECTION
# --------------------------
# Modify these to your own settings. You might have to
# contact your system administrator if you do not run
# your own web server. If the purpose of these
# parameters seems unclear, please see the README file.
#
BEGIN
{
$DEBUGGING = 1;
$emulate_matts_code= 0;
$secure = 1;
$allow_empty_ref = 1;
$max_recipients = 5;
$mailprog = '/usr/sbin/sendmail -oi -t';
$postmaster = 'fred@your.domain';
@referers = qw(www.your.domain);
@allow_mail_to = ();
@recipients = ();
%recipient_alias = (
'animals' => 'your-name@your.domain,your-name@somewhere-else.domain',
'plants' => 'foo@your.domain',
);
@valid_ENV = qw(REMOTE_HOST REMOTE_ADDR REMOTE_USER HTTP_USER_AGENT);
$locale = '';
$charset = 'iso-8859-1';
$date_fmt = '%A, %B %d, %Y at %H:%M:%S';
$style = '/css/nms.css';
$no_content = 0;
$double_spacing = 1;
$wrap_text = 0;
$wrap_style = 1;
$send_confirmation_mail = 0;
$confirmation_text = <<'END_OF_CONFIRMATION';
From: you@your.com
Subject: form submission

Thank you for your form submission.

END_OF_CONFIRMATION
#
# USER CONFIGURATION << END >>
# ----------------------------
# (no user serviceable parts beyond here)

Finally, the HTML form for the plants page will look like this:


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>What is your favorite plant ?</title>
<link rel="stylesheet" type="text/css" href="/css/nms.css" />
</head>
<body>
<form method="post" action="/cgi-bin/FormMail.pl">
<input type="hidden" name="subject" value="Favorite Plant" />
<input type="hidden" name="recipient" value="plants" />
<table>
<tr>
<td>What is your name ?</td>
<td><input type="text" name="name" /></td>
</tr>
<tr>
<td>What is your favorite plant ?</td>
<td><input type="text" name="plant" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" /></td>
</tr>
</table>
</form>
</body>
</html>