tmail.cgi:  Templated Mailer CGI

Created:  2/22/98
Last Modified: 3/17/99

What is TMail?
TMail is a simple, but powerful CGI tool used for sending web based form results to one or multiple email accounts. TMail requires NO CGI KNOWLEDGE to use! You may need BASIC knowledge of HTML and Web Forms to use TMail. At no time should the tmail.cgi script itself be editted or modified.

The simple setup:
The simplest way to have TMail just send you the info from your form is to using the following form method, action and hidden tags. All you have to do is change the _MAILTO value to YOUR email address and you're done:

    <FORM Method="post" Action="/cgi-bin/tmail/tmail.cgi">
    <input type="hidden" name="_MAILTO" value="your-email@address.com">
    <input type="hidden" name="_SUBJECT" value="Form Mail From mysite.com">
    <input type="hidden" name="_THANKS" value="/thanks.html">
    

This FORM and INPUT set can be used with any precreated form.

PLUG-N-PLAY TMAIL FORMS!
A few common forms are available here. Just grab the form HTML and throw it into your page and presto!


*** NOTE: ***
*** The following information and documentation is for advanced users. ***


Form Tag:
Your FORM HTML tag for TMail should look something like this:

     <FORM Method="post" Action="/cgi-bin/tmail/tmail.cgi"> 
This may vary depending on the location your CGI-BIN directory and other system settings.

HIDDEN Variables:
These are variables that you MAY set with in your <FORM></FORM> tags.  It is suggested you use HIDDEN INPUT tags to place these variables.  Example: <input type="hidden" name="_MAILTO" value="your@address.com">.

  • _MAILTO - The address to which TMail should mail the form results;
    IE. your@mailaddress.com
  • _MAILCC - The carbon copy addresses for the form results;
    IE. someone@somewhereelse.com
  • _SUBJECT - The subject line of the mailed results;
    IE. Form Results
  • _OCLOSE - The opening symbol for the response. To enclose the response in brackets, this would be [;
    IE. [
  • _ECLOSE - The closing symbol for the response.  To enclose the response in brackets, this would be ];
    IE. ]
  • _TEMPLATE - The name of the mail template this form submissions should shaped around.
    IE; example, order, info
  • _MISSING - The URL to forward people to if they missed a field when filling out this form;
    IE. /missinginfo.html, http://www.yourdomain.com/missing.html, etc.
  • _THANKS - The URL to forward visitors who successfully fill out the form to;
    IE. /thanks.html, http://www.yourdomain.com/thankyou.html, etc.
  • _LOG - If you're trying to debug a problem with your TMail implementation, set this hidden input with a value of 1 and TMail will keep a log at $CgiPath/tmail/logs/tmail_log.
NOTE: It is important to remember that all TMail internal use variables (such as those just above) MUST begin with an UNDERSCORE ("_") and MUST be in all CAPITAL letters. ALSO NOTE: _MAILTO is the only REQUIRED hidden variable.

Setting the "FROM" address of the form response:
The _FROMEMAIL variable can be used to specify the "From" address of the mail form response. It is especially convenient to request your visitor enter their e-mail into an input type such as:

    <input type="text" name="_FROMEMAIL" size=30>
This will send the mail as if they sent it from their email box allow you to simply reply to the form response in order to reply to them. You can also set this yourself using a hidden tag such as:
    <input type="hidden" name="_FROMEMAIL" value="forms@address.com">

TMail Templates
TMail uses templates to make your form output more legible.  You can edit your templates in a normal text editor offline and then deposit them in your cgi-bin/tmail/Templates directory. To create a template, just lay out the text the way you wish to receive it in e-mail. Enclose variable names within brackets ("[" and "]").

You may NOT have more than one variable on a TMail template line. TMail will only parse ONE variable per line of the template.

Requiring Variables With The Template:
A "*" just after the _OCLOSE marker (which is standardly "[") REQUIRES that field be filled out. This * SHOULD NOT be in the name="" field of your input tag. It should only appear in the template.

An Example Template:

      -----------------------
      Request For Information
      -----------------------

       First Name:  [*fname]
        Last Name:  [*lname]
          Address:  [*address1] 
                    [address2]
             City:  [*city]
            State:  [*state]
          Country:  [*country]
      Postal Code:  [*postal]

     Phone Number:  [*phone]
       Fax Number:  [fax]

    Email Address:  [email]

       Email Info?  [emailinfo]
         Fax Info?  [faxinfo]

Note: The HTML form for the above template specifies "faxinfo" and "emailinfo" to be checkboxes with the value set to "YES"

Sample TMail Forms and Templates:
Link to our Example Form or PLUG-N-PLAY Forms. These will give you a base to work with if need be. The template "example" from the example form does exist and can be editted from the template editor online. All templates found in the PLUG-N-PLAY Forms exist as well.

By:  Kenn Wagenheim (kennwag@iuinc.com)