MailForm.py Version 1.0.2
Python based email form CGI Written by Jeff Sykes

MailForm.py 1.0.2 Introduction     

MailForm.py 1.0.2 Configuration Fields |  MailForm.py 1.0.2 Example |  MailForm.py 1.0.2 Copyright


What is MailForm.py 1.0.2
MailForm.py is a CGI script which processes a form from the World Wide Web and sends the forms values to a given recipient or recipients via email.

History
MailForm.py is a Python port of Kelly Yancey's MailForm script, which was written in C. This was, in turn, a port of Matthew Wright's FormMail PERL script. I chose to write this port because of the growing number of Python users, and because I wanted a version of Kelly Yancey's MailForm that was Windows compatible. That and I happen to know some Python. MailForm.py stresses functionality over performance. I wanted to have all the form-controlled functionality of MailForm. I have not implemented FastCGI for this script, though that would probably be a good idea at some point! If you have code suggestions or snippets that would provide performance benefits, I would be grateful to receive and review them for inclusion in this script.

Getting Started
First, make sure that Python 2.1 or later is installed on your server. Record the location of the directory where the Python executable is located. For example, /usr/bin/python or C:\Python21\python.

Download a copy of the archive, which contains the script, named "mailform", and the HTML documentation. Unzip the script file in the CGI directory you will use on your webserver. You may want to check that your script has the proper umask/permission settings. On UNIX flavor systems, this is usually 755 for CGI scripts. You also may need to change what user/group "owns" the script using the chown command if you are on a UNIX/Linux server. If you are not sure about this, consult your system administrator.

Change the first or "shbang" line of the script to point to location of the Python executable you wrote down. When you do this, make sure to leave the "#!" intact. This allows the webserver to know how to start up Python to run this script. If you are on a Windows system, and use file extensions to tell your server which program to run scripts with, you will have to rename the script file to include an appropriate extension.

The script is now installed. There are two variables you may set within the script itself, which are detailed below.

Logging
MailForm.py can provide simple logging of environment variables and error occurences by setting the LOGGING_ENABLED parameter to YES. It will be NO by default. For example, the following setting would enable logging:

    LOGGING_ENABLED = YES

Log messages are output to the "mailform.log" file in the directory where the script runs. To indicate a different log file, simply change the LOG_PATH variable. For example:

    LOG_PATH = "/usr/jeff/jeff_mailform.log"

If you customize your log location, make sure your permissions are set to allow MailForm.py to write to the desired file and directory.

Mail Server Override
MailForm.py requires a "mail_server" field to be set in the forms that point to it. This variable tells MailForm.py what mail server to use to send its outgoing messages. You can override this by setting the MAIL_SERVER variable. If this variable is set, it will always be used by MailServer.py as the outgoing mail server, even if a "mail_server" field is included in the form pointing at MailForm.py. For example:

    MAIL_SERVER = "mail.cowz.com"

Contacting the Author
MailForm.py is written and maintained by Jeff Sykes.
I can be e-mailed at jeff@cowz.com.
Updates can be found at http://www.cowz.com/mailform/.
Please read the copyright before using MailForm.py.

Download

The latest version of MailForm can be downloaded as MailForm.py1.0.2.zip.

Please read the copyright before using MailForm.

Compatibility Notes

MailForm.py was written using Python 2.1. I have run the script on versions as high as 2.4 and t seems to be pretty solid. Because Python is an interpreted language, it should be portable across different operating systems. Your mileage may vary.

Examples

Try it out for yourself. Here is an example form you can fill out and it will mail the results to you so you can see for yourself what they look like.



MailForm.py 1.0.2 Introduction     

MailForm.py 1.0.2 Configuration Fields |  MailForm.py 1.0.2 Example |  MailForm.py 1.0.2 Copyright


Copyright © Jeff Sykes 2003