1and1 Help Centre Categories

print article

Example 5: Reply to the E-Mails

Suppose you have the setup in example 4 working, and you decide that you want to ask the visitors to the Favorite Plant page for their e-mail address in the form, and have FormMail.pl use the address that they enter as the 'From' address for the e-mail, so that you can hit 'reply' in your mail software to mail the visitor and strike up a conversation about their favorite plant.

FormMail will do this automatically so long as the input where the visitor sets their e-mail address is given the name "email". If the input where the visitor gives their name is called "realname" then FormMail will use this as the comment part of the e-mail address.

No change is needed to FormMail.pl for this example, we just add an "email" field to the form and rename the "name" input to "realname":

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