[0001]
[0002]
[0003]
[0004]
[0005]
[0006]
[0007]
[0008]
[0009]
[0010]
[0011]
[0012]
[0013]
[0014]
[0015]
[0016]
[0017]
[0018]
[0019]
[0020]
[0021]
[0022]
[0023]
[0024]
[0025]
[0026]
[0027]
[0028]
[0029]
[0030]
[0031]
[0032]
[0033]
[0034]
[0035]
[0036]
[0037]
[0038]
[0039]
[0040]
[0041]
[0042]
[0043]
[0044]
[0045]
[0046]
[0047]
[0048]
[0049]
[0050]
[0051]
[0052]
[0053]
[0054]
[0055]
[0056]
[0057]
[0058]
[0059]
[0060]
[0061]
[0062]
[0063]
[0064]
[0065]
[0066]
[0067]
[0068]
[0069]
[0070]
[0071]
[0072]
[0073]
[0074]
[0075]
[0076]
[0077]
[0078]
[0079]
[0080]
[0081]
[0082]
[0083]
[0084]
[0085]
[0086]
[0087]
[0088]
[0089]
[0090]
[0091]
[0092]
[0093]
[0094]
[0095]
[0096]
[0097]
[0098]
[0099]
[0100]
[0101]
[0102]
[0103]
[0104]
[0105]
[0106]
[0107]
[0108]
[0109]
[0110]
[0111]
[0112]
[0113]
[0114]
<HTML>
<HEAD><TITLE>Tmail demo</TITLE></HEAD><BODY>
<H1>Template-driven Mail Script</H1>
The template-driven mail script is a simple yet flexible way to deliver
form data from an HTML form to a user via VMS callable mail.  The script
scans a template file to obtain the addressee, subject, and body of the
message to be sent.  The template may include named tags that get replaced
during the scan by the corresponding fields of the form data included with the
request.
<h2>Generating a form to use tmail</h2>
To use tmail you must create a form that specifies an action of POST and
the tmail script as the action URL with the virtual path of the template
file as the URL's path info (See <A HREF="#SAMPHTML">sample form's HTML</A>).
<P>
The sample form below specifies <A HREF="/wasd_root/src/osu/tmail.tmail">/wasd_root/src/osu/tmail.tmail</A>
as it's <A HREF="#TMPL">template file.</A>  The template file's to: field must be changed
to specify the actual user you want the mail to go to.
<HR>
<FORM method="POST" action="/htbin/tmail/wasd_root/src/osu/tmail.tmail">
Subject: <input type="text" name="subject" size=40 maxlength=100><BR>
Title: <input type="text" name="title" size=40 maxlength=100><BR>
<DL><DT>Body:</DT>

<DD><textarea a name="msg" size=80 rows=10 cols=60></textarea></DD>
</DL><BR>
<input type="checkbox" name="urgent"> urgent<BR>
<input type="submit" value=" send "> <input type="reset" value=" clear ">
</FORM>
<HR>

<h2><A NAME="SAMPHTML">Sample form's HTML</A></h2>
<PRE>
&lt;FORM method="POST" action="/htbin/tmail/wasd_root/src/osu/tmail.tmail"&gt;
Subject: &lt;input type="text" name="subject" size=40 maxlength=100&gt;&lt;BR&gt;
Title: &lt;input type="text" name="title" size=40 maxlength=100&gt;&lt;BR&gt;
&lt;DL&gt;&lt;DT&gt;Body:&lt;/DT&gt;
&lt;DD&gt;&lt;textarea a name="msg" size=80 rows=10 cols=60&gt;&lt;/textarea&gt;&lt;/DD&gt;
&lt;/DL&gt;&lt;P&gt;
&lt;input type="checkbox" name="urgent"&gt; urgent&lt;BR&gt;
&lt;input type="submit" value=" send "&gt; &lt;input type="reset" value=" clear "&gt;
&lt;/FORM&gt;
</PRE>
<h2><A NAME="TMPL">Template File Format</A></h2>
The template file consists of 1 or more header lines, a blank line (zero
length), and zero or more body lines.  A header line has a label terminated
by a colon and an argument starting at the first non-space charater after
the label and continuing to the end-of line.  The body lines become
the body of the sent mail message.
<P>
The very first line of a template file must contain "tmail: xxx" where
xxx is a version number.  This requirement is so the tmail script doesn't
waste time trying to interpret a file that wasn't explicitly written as
a tmail template.
<DL>
<DT><h3>Labels</h3></DT>
<DD><DL>
<DT>To:</DT>
<DD>Specifies the email address of the person to receive the mail.  This
label is required</DD>
<DT>Subject:</DT>
<DD>Specifies an optional subject line to use for the message.</DD>
<DT>Success:</DT>
<DD>Specifies an alternate URL to return to indicate a successful send,
may be either a local or remote redirect.</DD>
<DT>Success-sts:</DT>
<DD>Specifies a alternate HTTP return code to use rather than the standard
200 code.  Specify a code of 204 to get a 'slient' repsonse to the post.
<DT>Tmail:</DT>
<DD>Signature used to indicate that this is a tmail template.  The tmail:
header line must be the first line of the template file.
</DD>
</DL></DD></DL>
</UL>
<h3>Tags</h3>
A tag marks a point in template file where form data or CGI environment
data is to be inserted.  The format of a tag is [field-name], [%cgi-var], or
[%%cmd], where field-name is an input field in the form, cgi-var is a CGI 
variable name and cmd is one of the special command keywords described below.
Note that names inside tags are case sensitive.  Tags may be placed in both 
body lines and header lines;
<P>
To place a literal "[" or "]" in the template file, specify "[[" and "[]"
respectively.
<h3>Command (%%) tags</h3>
Tags  prefixed with 2 percent signs (e.g. [%%end]) indicate special actions
that tmail is to take during template processing.
<P>
<DL>
<DT>%%end</DT><DD>Marks logical end of template, lines following this tag
will are assumed to be a CGI response to send instead of the normal
confirmation message.  The first line following this tag must be a
content-type header lines (e.g. "content-type text/html")  followed by
a blank line.</DD><P>
<DT>%%entify</DT><DD>Causes the script to convert any <B>&lt;</B>, <B>&gt;</B>, 
or <B>&amp;</B> characters present in any succeeding tag expansions to their 
HTML 'entity' forms (e.g. '<B>&lt;</B>' ==&gt; '<B>&amp;lt;</B>').  Entification is
off by default for the portion of the template prior to [%%end] and on for
the portion after the [%%end]</DD><P>
<DT>%%noentify</DT><DD>Turns off entification (see entify above).
</DD>
</DL>

<h3>Conditional expansion</h3>
You may optionally create tags with one of the extended formats
[field-name:text] or [field-name?text].  Tags with the [field-name:text] format
will substitute 'text' for a non-null field value and a null string if
the field value is null.  Tags with the [field-name?text] format will
substitute 'text' for "on" and a null string otherwise (i.e. tests setting
for checkbox input items).
<h2>Acknowledgements</h2>
The inspiration for tmail is the MIT cgiemail script, which uses unix sendmail
as the mail transport.  The code for tmail started life as Dick Munroe's
cgi-mailto script.
</BODY></HTML>