NTMailer 1.71
by Ivan M. Hendricks
Changes from 1.70 to 1.71
Changes from 1.70 to 1.70
Changes from 1.62 to 1.63
Changes from 1.51 to 1.60
Introduction
NTMailer is a cgi program that runs only on NT/Windows 95 based web servers and it's compiled on the
Intel platform. With no experience with c/c++ or perl and a little knowledge of HTML coding, you can write a full fledged form no time at all. The program is very powerful and has many features.
I believe in learn by example, so in the docs you will see an example after every item. Sometimes I cannot always express what I want to say, so I do it in examples.
Features:
-Don't need to know a programming language like c/c++ or perl
-Design your own template file that has the look and feel of HTML coding.
-ALL configuration parameters are done within the template file.
-Has required fields with custom 'required' error messages.
-You design how the error html page will look like and what it will say depending on the
missing fields.
-Can send form contents to one or more people.
-Can do auto-response messages to the person filling out the form.
-Can send auto-response messages to several people.
-Ability to include the forms data on your success page, your e-mail and the automated
response e-mail. This allows you to do some sort of form verification.
-Design your own success page with standard HTML tags.
-As well as sending out an e-mail, you will also have to option to save the information
into a pipe (|) delimited file for later viewing in a spreadsheet that supports
delimiters (Microsoft Excel) or import into a database that supports flat file imports
by delimiters.
-Ability to use server environment variables in message body that you will receive, the
auto-response message and the success page.
-Multiple template files and only one cgi program
-Does not require a separate mailer, because it's all built in! Conforms to rfc821 and rfc822
-Support for a few simple types (char, email, int) and one I made up.
How to use
NTMailer is designed to be run as a cgi script. The program must be called from within the ACTION of your <form> and you also need to specify a template file. The template file is a parameter of the cgi script. This means that you must call ntmailer by saying "ntmailer.exe?" what follows after the question mark is the name of your template file.
Example
Let’s say that my template filename is bug.txt, then I would call NTMailer like:
<form action="/cgi-bin/ntmailer.exe?bug.txt" method="POST">
Template File
This is the file in which all form variables are declared, response messages are created and mail server
configuration is specified. Besides your html file, this is the only other configuration file that is required.
Remember, the tags are not case sensitive and there MUST NOT be any spaces between the attribute name and the equals sign (=) as well as between the equal sign and the double quote ("), otherwise your attribute will be ignored or an error will be produced. Attributes that are italics are optional parameters.
The first is the <formdata>...</formdata> tag. All variables from the form have to be declared here, or
else you will not have visibility to them. The only tag in the <formdata> area is the <name> attribute.
With it there are a few additional options which are outlined below.
Syntax
<formdata>
<name="variable"
required
requiredErr="text"
type="{char|int|email}"
typeErr="text"
sendto
replyto
respondto>
...
</formdata>
NAME="variable" where variable is the variable name from your form ( <input type=hidden name="variable">)
REQUIRED specifies that the field is required. If you specify REQUIRED, then you must specify a REQUIREDERR.
REQUIREDERR="text" is where you state the message to display when an error occurs. If you did not
specify REQUIRED, then you should not have this tag. This information will be plugged
into <errTemplate>..</errTemplate>, which is discussed later.
TYPE is a way for you to check for certain things. At this time, there are only 3 types allowed.
char - specifies that anything can be accepted.
int - specifies that this field can only accept numeric values
email - specifies that this field must have at least an @ sign and a period (.)
You can actually leave out the ‘type’ attribute if your field is going to be a char. I placed the ‘char’
type in there for future usage as well as backward compatibility. Although it might be a good idea to put it in.
TYPEERR is used to define an error message in the event that the field fails the type checking.
SENDTO is how you specify to whom you want the contents of this form sent to. You are allowed to
have multiple SENDTO's specified. Also, the SENDTO and the RESPONDTO items cannot coexist within
same<'name> attribute. It's either one or the other, not both. The application will provide an error if this
occurs.
REPLYTO. This is what will be in the reply-to field on the e-mail message the you receive. Makes it easier to respond to users mail from the form.
RESPONDTO. Based on the information provided by this form tag (an e-mail address), this will be
to whom you will send a auto-response message that you specify in <rmsgbody>. This will be discussed later.
The example below is a small sample, but has all the possible combinations of the <name> attribute and it's
associated items.
Example:
<formdata>
<name="sendto" sendto>
<name="fname"
required
requiredErr="First name is missing">
<name="lname"
required
requiredErr="Last name is missing"
type="char">
<name="phone"
type="int"
typeErr="Only numbers are accepted in the phone number field">
<name="e-mail"
required
requiredErr="Need your e-mail address"
type="email"
typeErr="Your e-mail address is incorrect. Please check it."
replyto
respondto>
</formdata>
The rest of the template file consists of specifying mail server information as well as designing
your response messages
<smtpserver>...</smtpserver> Name of your mail server.
Example: <smtpserver>mail.mymailserver.com</smtpserver>
<sender>...</sender> The e-mail address that the mail server knows about. You can use form information here.
Example: <sender>me@mymailserver.com</sender> or <sender>$email$</sender>
<subject>...</subject> Subject line that will be on the sendto's mail message. You can use form information here.
Example: <subject>This is a test from $username$</subject>
<rsubject>…</rsubject> Subject line that will be on the respondto’s mail message. . You can use form information here.
Example: <subject>Thankyou $username$, for your submission</subject>
<msgbody>...</msgbody> This is the message body that will be sent to the people that are specified
as a 'sendto'. In order to include the variables specified in <formdata>, put a dollar sign($) around the
variable name. You may use the variable name more than once, if you want.
Example: <msgbody>
Name: $fname$ $lname$
phone: $phone$
e-mail address: $e-mail$
First Name: $fname$
</msgbody>
<rmsgbody>...</rmsgbody> This is the body message that will be send to the people that are specified
as a 'respondto'. Again, in order to include the variables specified in <formdata>, put a dollar sign($) around the variable name. You may use the variable name more than once, if you want.
Example: <rmsgbody>
Thankyou, $fname$
We will be contacting you ASAP at $e-mail$.
</rmsgbody>
<succeedmsg>...</succeedmsg> Here is the html page that will be displayed if all the mail messages where sent successfully and there are no form errors. You can specify any standard HTML tag. This may include text, graphics and anything else that you need in order to keep the same look & feel of your other homepages. The only thing that you will need to remember is that when specifying images or links, be sure to state the full qualified path (i.e.: http://www.realnetnw.com/images/logo.gif). In order to include the variables specified in <formdata>, put a dollar sign($) around the variable name. You may use the variable name more than once, if you want.
Example:<succeedmsg>
<html><body bgcolor="#ffffff">
<p align=center><h1>
<image src="http://www.realnetnw.com/miceuro/images/logo.gif"><br>
Thankyou for submitting your form $fname$. We will be contacting you soon
at $e-mail$.</body></html>
<errtemplate>...<errtemplate> Create your html page that will be used in the even the person leaves
a required field blank. As in the <succeedmsg> tag, you can use standard html tags as well as the forms
variables in order to produce your page. Use the $err$ in order to dump out the information you entered
in <formdata> under 'requirederr'.
Example: <errtemplate>
<html><body bgcolor="#ffffff">
<p align=center><h1>
<image src="http://www.realnetnw.com/miceuro/images/logo.gif"><br>
The following errors occurred:<br>
$err$<p>
Please complete and resubmit.
<form method="POST"......>
<input type="hidden" name="sendto" value="$sendto$"><br>
Your first name: <input type="text" name="fname" value="$fname$"><br>
Your last name: <input type="text" name="fname" value="$lname$"><br>
You phone number: <input type="text" name="fname" value="$phone$"><br>
Your e-mail addr: <input type="text" name="fname" value="$e-mail$"><br>
<input type="submit" value="submit me"><br>
</form>
</body></html>
</errtemplate>
<dfile>...</dfile> Want to be able to store your information in a file as well as being sent and e-mail?
Well, here it is. Within the tags, specify a file in which you want your information appended to. If the
file does not exist, then ntmailer will create it for you. If you use this tag, then you must also use the
<dfileformat> tag.
Example: <dfile>formdata.dat</dfile>
<dfileformat>...<dfileformat> Specify how you want the information stored to the file. In order to include
the variables specified in <formdata>, put a dollar sign($) around the variable name. You may use the
variable name more than once, if you want. I know one person who uses this in order to page him if
he receives a new message through his form. His paging software requires that flat file to be in a
specific format. Another possibility is for import into an excel spreadsheet or into a database (bcp).
Example: <dfileformat>$fname$, $lname$, $phone$, $e-mail$</dfileformat>
Server environment variables
You are allowed to use environment variables in <succeedmsg>, <errtemplate>, <msgbody>, <rmsgbody>, <subject>, <rsubject> and <dfileformat>. To use this feature, place a dollar sign ($) around the environment variable that you want to display (i.e.: $QUERY_STRING$).
Application reserved variables
You can use reserved variables anywhere form information can be used (almost everywhere). At this time, there are only two reserved variables.
$systemdate$ - Prints the date of the server.
$systemtime$ - Prints the time of the server.
That's it. There is a sample html file as well as a template file. This was taken from an actual site.
Bug,comments and enhancement reports are very appreciated. I try my best to grant everyone’s wish, so
give me your suggestions. I encourage you to report any problems you might be having with
the application. Who knows, you might have stumbled across a bug.
Ivan Hendricks
ivanh@aracnet.com
NTMailer homepage: http://www.realnetnw.com/miceuro
Copyright 1996 Ivan Hendricks. All rights reserved
THIS SOFTWARE IS PROVIDED BY IVAN HENDRICKS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, BUT NOT LIMITED TO, ARE DISCLAIMED.
IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.