CMPS 335 Advanced Web Publishing
Perl CGI Programming

Assignment 3, Spring 2002
Emailing Form Data


Forms are used to obtain data from visitors.  Most form owners want the data returned to them.  One of the common uses of email is to email form data.  For this assignment, you need to design and create a registration form to collect data and write a CGI script to email the data back to you.

Simple Mail Transfer Protocol (SMTP) is the specification used to transmit email messages across the Internet.  If you have an email account, you are using an SMTP mail server.  The most popular implementation of SMTP is the sendmail program.  A CGI script can communicate with the sendmail program by opening a pipe to it with the open statement.  The sendmail program sends messages to one or more recipients.  From a Unix platform, you can use sendmail directly without going through an email client program such as Nestscape mail or Eudora.

Part A -- Creating A Web-based Registration Form

Write an HTML document to generate a registration form for obtaining visitor's information.  This registration form should contain at least the following elements:
(Example of a Completed Registration Form)

Part B -- Creating a CGI Script for Emailing Form Data

The address of the sendmail program on our Web server is: /usr/sbin/sendmail.  Your CGI script should open a pipe to re-direct the output of the script to the sendmail program..  Your script also needs to specify the recipient of the email.  The recipient should be your email address for this assignment.  These things can be accomplished by the following statements:


With the -t switch, The sendmail program scans the message for recipient address.  Your script then prints out the header information for mail message, the data (mail message), and closes the input stream so the message actually gets mailed.
Finally, your script generates a Thank You page to acknowledge receipt of the registration data.  On this Thank You page, your script should also display the registration data.
(Example of a Thank You web page)

Thank you for your registration

  Click Here for an example of registration form
  Return to Home Page