CGI Scripting

Using the mailto Script
BASICS

The mailto script is used to gather data from a form and email it to the specified address. If you want to use forms on your web site to collect data from your customers, get feedback, or take orders, then you can use the mailto script. There is also another script that you can use called appendto that will be covered in another section. .

The Form Page

Follow the steps below for using the mailto script.

  1. Create your HTML file with the form on it. Forms can be created using most Web authoring programs. If you don't know how to create forms, refer to the following URLs for creating forms:

    Webcom's Forms Tutorial
    HTML Forms Tutorial by NCSA

  2. Once you've created your form, you will need to set the METHOD of the form to POST and the ACTION of the form to http://home.earthlink.net/cgi-bin/mailto.

    <FORM METHOD="POST" ACTION="http://home.earthlink.net/cgi-bin/mailto">

  3. You will also need to add the two hidden fields below in between the begin form tag and the end form tag:

    <INPUT TYPE="HIDDEN" NAME="RECIPIENT" VALUE="user@domain.com">

    <INPUT TYPE="HIDDEN" NAME="THANKURL" VALUE="URL_for_a_thankyou_page">

    where user@domain.com is the email address to which you want the data from the form sent and URL_for_a_thankyou_page is the URL of a page (e.g., http://home.earthlink.net/~username/thankyou.html) that you will need to create telling the user that the data from the form has been sent.

    The words RECIPIENT and THANKURL are keywords that the script will need. Both keywords are case sensitive. You will get a Server error if the script does not find both of the keywords and if the cases don't match to the ones above.

Below is a sample form that you can copy and paste with very little modification.

<!-- begin sample html page -->

<html>

<head>
<title>Sample Form</title>
</head>

<body>

<h1>Sample Form</h1>

<hr>

<form method="post" action="http://home.earthlink.net/cgi-bin/mailto">
<input type="hidden" name="RECIPIENT" value="user@domain.com">
<input type="hidden" name="THANKURL" value="http://home.earthlink.net/~username/thankyou.html">
<p>
<b>Name:</b><input type="text" name="name" size="30"><br>
<b>Email:</b><input type="text" name="email" size="30"><p>
<b>Comments:</b><br>
<textarea name="comments" rows="10" cols="50"></textarea>
<p>
<input type="submit" value="Send">
<input type="reset" value="Clear">
</form>
<p>

<hr>

</body>

</html>

<!-- end sample html page -->

On the above sample form, you will need to replace username with your own EarthLink username and user@domain.com with the email address to which you want the data from the form sent. Feel free to copy and paste the sample form above to your favorite text editor and then save it as form.html.

You will also need to create your own confirmation (thank you) page. For your convenience, we have provided a copy and paste sample confirmation page below.

Sample Confirmation Page

The confirmation page is displayed after the visitor has clicked on the Submit button and the data from the form has been saved. As with the sample above, you may copy and paste from this directly into an HTML file.

<!-- begin sample thank you page -->

<html>

<head>
<title>Thank You!!!</title>
</head>

<body>

<center>

<h1>Thank You!!!</h1>

</center>

<p>
<center>
The information you provided has been sent. We will get back with you as soon as we can.
</center>
<p>

</body>

</html>

<!-- end sample thank you page -->

Feel free to copy and paste the sample thank you page above to your favorite text editor and then save it as thankyou.html.

Other Related Pages

Forms Menu
Confirmation Page
Options
Putting It All Together
Frequently Asked Questions



Member Web Support Main Menu