This guide will help you write a WWW form that sends an e-mail message to you. The following steps are required:
The following steps are optional.
Before you start receiving e-mail messages through the web, you should decide what these messages should look like. Create an ASCII file, called an e-mail template, that looks something like this:
To: me@mydomain.com HEADER LINES
Subject: Questionnairre
blank line
What is your name? [yourname] BODY
What is your address? [address]
What is your zip code? [zipcode]
The template file will be used by the MailPost program, so before you upload the file to your WWW server, be careful to follow these guidelines:
Now go ahead and upload your e-mail template to the WWW server and look at it with your WWW browser.
Usually, when you create an HTML form, you need to give people a way to supply an email address. Now you need to add a line to the top of your email template like this:
From: [email]
So now the template file looks like:
To: me@mydomain.com
From: [email]
Subject: Questionnairre
What is your name? [yourname]
What is your email address? [email]
What is your address? [address]
What is your zipcode? [zipcode]
The trickiest part of the HTML form is getting the ACTION of your HTML form set correctly. There are two parts to the ACTION URL.
http://www.mydomain.com/cgi-location/MailPost.exe/mydirectory/template.txt \ /\ / `---------------- Part 1 ---------------------' ` ------ Part 2 --------'
For our example, the HTML code would look like this:
<FORM METHOD="POST" ACTION="http://www.mydomain.com/cgi-directory/MailPost.exe/mydirectory/template.txt"> <P>Your e-mail address: <INPUT NAME="email"></P> <P>Your name: <INPUT NAME="yourname"></P> <P>Your address: <INPUT NAME="address"></P> <P>Your zipcode: <INPUT NAME="zipcode"></P> <P><INPUT TYPE="submit" value="Send e-mail"></P> </FORM>
This is a very simple example. Note that the NAME of each input corresponds to what you previously put in the email template. In this example they are email, yourname, address, and zipcode. This is the key concept in using MailPost. Be careful to make them exactly the same; if you put NAME="yourname" in your HTML form and [name] in your email template, the input will not show up in the email.
You can test your MailPost form without sending an email message by including the hidden variable named *nosend* in your HTML form:
<INPUT TYPE="HIDDEN" NAME="*nosend*">
MailPost will return a sample of what your email message will look like. If all looks good, you can then go "live" by removing the *nosend* variable in your HTML form.
To learn to create more complicated forms, read NCSA's guide. All of their example forms can be converted to MailPost forms merely by changing the ACTION. Unlike other forms-to-email programs, you are not required to use hidden inputs with special names.
All types of inputs (radio buttons, etc.) work the same way. Each input needs a unique NAME, and that name must appear within square brackets in your email template. It's that simple.
Once you've set the ACTION correctly in your HTML form (and you've removed the *nosend* input variable if you used it), try it out! You should receive an email message with the processed form. If not, go back and make sure you correctly followed the instructions on this page.
If it works, you've successfully mastered the fundamentals of MailPost. Congratulations!
When mail is sent, a page appears with the text of the email message. You may use a hidden variable in your HTML form called addendum to add your own text. Here is a simple example:
<INPUT TYPE="hidden" NAME="addendum" VALUE="Thank you!">
You may also place HTML codes in the addendum variable as well, although they may or may not be supported by your user's browser.
If you don't like the default page that comes up when email is successfully sent, you can specify an alternate URL using a hidden variable called success in your HTML form, e.g.
<INPUT TYPE="hidden" NAME="success" VALUE="http://www.mydomain.com/thanks.html">
Note: You MUST use the full http: path, not relative paths to the document.
There is no way to make this alternate success page contain information the user submitted in the form.
If you would like to automatically reject forms with certain inputs left blank, add the prefix required- to the name of the input in both your HTML form and your email template. Here is an example:
In the HTML form:
Your email address: <INPUT NAME="required-email">
In the email template
Your email: [required-email]
If you don't like the default page that comes up when a required field is left blank, you can specify an alternate URL using a hidden variable called *on-error* in your HTML form, e.g.
<INPUT TYPE="hidden" NAME="*on-error*" VALUE="http://www.mydomain.com/error.html">
Note: You MUST use the full http: path, not relative paths to the document.
MailPost allows you to embed CGI environment variables into your template file by simply prefacing the CGI environment name with a dollar sign "$". For example:
[$HTTP_REFERER]
will put the referring URL into the email message. All CGI environment variables are uppercase.
You can insert the Date & Time into your email message by inserting the special template variable *date-time* into your template file.
From: mailpost@mcenter.com
To: mailpost@mcenter.com
Subject: Date & Time variable
This message was generated at: [*date-time*]
This variable is not for use in the header of the template file, only the body of the template file. The *date-time* variable uses your system's "short" date & time settings under Control Panel | Regional Settings
Beginning with version v3.04, MailPost can create and send an automatic reply message. MailPost allows you to send a generic or a customized Auto Reply message. The customized Auto Reply message is created using a template file, just as you do for your form. All variables that are available to your form's template file are available to the Auto Reply template. The Auto Reply feature is enabled by adding a line in the header section of your form's template file.
To use the Auto Reply feature, follow these steps:
In the template file for your form, insert the "X-AutoReply:"
header, as in:
From: mailpost@mcenter.com To: you@there.com Subject: Information X-AutoReply: Thanks for visiting our website. etc., etc..
If you do not specify a template file to use for the Auto Reply message,
MailPost will create a generic message and email it. If you do specify an
Auto Reply template file, MailPost will use that template file to format
your Auto Reply message.
Note: The Auto Reply's template file must reside in the same
directory as the template file used for the form. If it is not found,
MailPost will generate its' generic Auto Reply message.
If you wanted to create a custom Auto Reply message using a reply template file named "form-reply.txt", the form's template file would be:
From: mailpost@mcenter.com To: you@there.com Subject: Information X-AutoReply: form-reply.txt
Remember that your Auto Reply template takes on the same structure as a regular form template. You include the To:, From: and Subject: headers, separate the headers and body with a blank line, which is followed by the body of the message. All variable substitutions will take place, just as it did in the form's template file.
| required- | makes the field a required field | ||
| *nosend* | displays what the message will look like, but does not email it | ||
| *debug* | shows MailPost system variables in the returned HTML | ||
| *on-error* | redirects user to the specified page if a required field is missing | ||
| append | adds additional text to the results page | ||
| success | allows the user to be redirected to another page after email is sent | ||
| *wrap-text* | allows the user to specify the length of the lines in the email mesage. Set the VALUE of *wrap-text* to how long your lines should be. Use this variable if you need to manually line wrap your email messages. If it is not used, line wrapping is handled by client's software. | ||
| *redirect* | Used with the redirect feature. | ||
| .dflt | This extension is used with a form variable's name to specify the default value of the variable | ||
| .URLencode | Variable name extension used with a HIDDEN form variable. This instructs MailPost to encode the value of this variable for URL passing, such as to a CGI program. | ||
| form. | Variable name extension. This extension tells MailPost to use the value of another form variable for this form variable. If the form had two variables, named A and B, and variable B had the value form.A , when the form is processed, variable B will be given whatever value variable A has. | ||
| Variable name extension. This extension makes MailPost check if the variable is a properly formatted email address. | |||
| *unique* | Used as a VALUE of a form variable. This causes a "unique" 8 character "word" to be generated for this variable. It is based on the date and time. | ||
| |CRLF| | Inserts a Carriage return and Line feed. This is usually used when working with multi-select listboxes | ||
| *date-time* | Used in the template file only.
This will insert the system's current Date & Time in the email message. It uses the "short" date and time settings under control panel.| regional settings Do not use this variable in the header of the template, only in the body. |
||
| X-AutoReply: | Used in header section of form
template only
See the Auto Reply section |
||
| X-SaveAs: | Used in header section of form
template only
See the Saving results to a file section |
||
| X-SaveUsing: | Used in header section of form
template only
See the Saving results to a file section |
||
| *save-as* | Used in the body of the form template
See the Saving results to a file section |
||
| *error-msg* | Used in the HTML *on-error* page Displays the error that occured | ||
| *noHTML* | Used in the X-SaveUsing template file
This converts HTML to printable characters |
MailPost Homepage | Help Index
For additional information not presented here, email mailpost@mcenter.com
For problems concerning this site, email webmaster@mcenter.com