Creating a Form Using the ECN email-form


Historically ECN has offered a email-form tool which allowed users to submit forms to a CGI script and have the information submitted emailed to an email address. Beginning in August 2003 this script was disabled because of abuse.

If you are using the Engineering Web Cluster you can use the Zope version of the


ECN Form Email Tool. Otherwise you will need to install a custom script to handle your form submission.

Creating the Form

The form should contain hidden elements for the following fields:

  • subject - The subject of the email
  • ack_url - The URL where the user is directed after submitting the form

Below is an example HTML form:

<form method="post" action="email.cgi">
<input type="hidden" name="subject" value="Example Email Submission">
<input type="hidden" name="ack_url" value="">

Name: <input type="text" name="Name" size="35"> <br>
Message: <textarea name="Message" rows="7" cols="45"></textarea><br>
<input type="submit" value="Send Email">

Once you have created the HTML form you will need to create the script to process the form. ECN has created a sample Python script which you can customize to handle form submissions. First Download the script (Right click and Save As). You will need to change the toaddr (To Address) and fromaddr (From Address) variables. This script can be placed in the same folder as your HTML form. The permissions need to be set such that it can be executed by everyone, to do this type:

> chmod a+rx email.cgi

In the folder where the email.cgi script was saved. Once this is complete your form should work correctly. A code listing of the script is provided below:


import smtplib, cgi, string

form = cgi.FieldStorage()

# Change the lines below to specify the TO and
# FROM addresses

toaddr = ''
fromaddr = ''

# Special form fields used by the email.cgi
# script

ack_url = form.getvalue('ack_url',None)
ack_text = form.getvalue('ack_text','Your submission was successful')
subject = form.getvalue('subject', '')

# form fields to skip
to_skip = ['ack_url', 'ack_text', 'subject', 'to']

# create the email headers

msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (fromaddr, toaddr, subject)

for key in form.keys():
    if string.lower(key) in to_skip: continue
    msg = msg + "%s: %s\n\n" % (key, form.getvalue(key))

server = smtplib.SMTP('')
server.sendmail(fromaddr, toaddr, msg)

if ack_url:
    print "Location: %s" % (ack_url)

    print "Content-type: text/html"
    print ack_text

Download this script (Right click and Save As)

Last modified: 2014/01/27 16:05:11.376373 US/Eastern by joshua.g.davis.1
Created: 2007/03/21 12:03:5.210000 GMT-4 by brian.r.brinegar.1.



Type in a few keywords describing what information you are looking for in the text box below.

Admin Options: Edit this Document