STAMP - Secure, Template-Aware Mail Processor

Published at: 2002.06.02 18:14:04 | Back to TOC

NAME

STAMP - Secure, Template-Aware Mail Processor

VERSION

    $Revision: 1.9 $
    $Date: 2001/10/01 21:09:40 $

SYNOPSIS

STAMP is a secure, generic HTML form mailer written in Perl. It is easy to set up and provides security against your system being used as a spam gateway. STAMP also lets you customize generated email submissions using templates, and provides optional PGP encryption of email messages.

DESCRIPTION

STAMP provides secure form processing and email generation, and supports using templates to control and customize the generated email message. It is more secure than the standard FormMail script because it relies on a server-side configuration file to set the recipient and subject of an email message; this makes it impossible for spammers to use your mail processing system as a spam gateway.

STAMP also allows you to PGP-encrypt all messages sent through the system. This functionality requires that you have the Crypt::OpenPGP module installed on your server; Crypt::OpenPGP provides a pure-Perl implementation of the OpenPGP standard, and is compatible with all PGP implementations (PGP, GnuPG, etc.).

STAMP provides many configuration options to customize the appearance of the email messages it generates. Foremost among these options is the ability to use user-defined templates to control the appearance. These templates act like form letters, in that they contain hooks to insert the values of the fields on your form.

CONFIGURATION OPTIONS

STAMP uses server-side configuration files with hard-coded recipient and subject values to provide security against spammers. In addition to those fields, configuration files are used to set many other form-specific options.

The configuration file has the following format:

Empty lines and lines starting with # are comments.

All other lines are of the format keyword arguments. Possible keywords are:

MESSAGE ENCRYPTION

To set up encryption of all messages sent through STAMP, you must first ensure that your server has Crypt::OpenPGP installed. Talk to your system administrators if you're not sure.

Once you know that Crypt::OpenPGP is installed, follow these instructions to set up encryption:

  1. Export your PGP public key. You should not include the private/secret key part of your key; only the public part is required.

  2. Upload the exported key to your webserver, and take not of the location where you uploaded it.

  3. Open your STAMP configuration file.

  4. Add an EncryptKey directive, specifying the email address associated with the public key that you exported--this is probably your personal email address. For example:

        EncryptKey foo@bar.com
    

  5. Add an EncryptPublicKeyRing directive, specifying the path to the exported key you uploaded in Step 2. For example:

        EncryptPublicKeyRing /path/to/key.asc
    

  6. Add an EncryptCompat directive, specifying the compatibility mode for the encryption; this should correspond to the PGP implementation that you will be using to decrypt encrypted STAMP messages. Take a look at the documentation for EncryptCompat, above, for a list of possible values. For example:

        EncryptCompat PGP2
    

That's it, you're done! All mail sent through the particular STAMP form for which you set up encryption will now be encrypted.

TEMPLATE SYNTAX

A mail template for email generation might look like this:

    Hi,
    This is an automated message generated from a form
    submission on your web site. The form was submitted
    by <TMPL_VAR NAME="fname"> <TMPL_VAR NAME="lname">, who
    is interested in the <TMPL_VAR NAME="interest"> aspect
    of your business.

    Here is the information posted through the form:

    First Name       <TMPL_VAR NAME="fname">
    Last Name        <TMPL_VAR NAME="lname">
    Age              <TMPL_VAR NAME="age">
    Phone Number     <TMPL_VAR NAME="phone">
    Email Address    <TMPL_VAR NAME="email">

    Please contact this person as soon as possible.

In the above examples, the labels like fname, lname, etc. should match the labels for the fields in your form. The <TMPL_VAR NAME=``foo''> statements will be completely replaced by the values of those fields, when the form is submitted. For example, if you have a form field called age:

    <input name="age" size="3">

and a user fills in the value 56, the Age line above will read

    Age              56

FORM FIELDS

To use STAMP, your HTML form must contain a field called _form; this will generally be a hidden input field, and it tells STAMP which form was submitted, so that it can pull the necessary information out of the configuration file.

The _form field might look like this:

    <input type="hidden" name="_form" value="form1">

In addition, if you'd like the From address of the generated email message to contain the user's email address, you should create an email field in your form for the user to fill in:

    <input name="email">

The value of this field will be used as the From address.

AUTHOR & COPYRIGHTS

Benjamin Trott, ben@rhumba.pair.com

Except where otherwise noted, STAMP is Copyright (c) 2001, Benjamin Trott. All rights reserved. STAMP is free software; you may redistribute it and/or modify it under the same terms as Perl itself.