3.1) How do I send mail from a webpage?
You'll want to use
the Netmar mail script. It has many powerful features that you can use
to set up your webpages and get mail from forms.
Here's how to use it:
Mail Script
Netmar offers one of the most robust and feature-laden FORM-to-Email gateway
programs available anywhere on the Internet. The Mail script can process
the output of an HTML form, check it against a set of rules to determine
whether or not it should be accepted, convert into one or more formatted
email messages, and return a formatted response to the browser, complete
with data from the form embedded within. It can then repost all of the
given data to ANOTHER script for special processing. If that sounds like
too much, and you just want to mail a simple form, it can do that too.
The Mail script is available by setting your FORM ACTION tag equal to
"/cgi-bin/mail" -
<form action="/cgi-bin/mail">
In addition, there are a number of special variables which tell the script
how to operate.
Here is a sample
form that demonstrates use of all of the mail script's features. Feel
free to save and reuse it.
Here are the other files that would go with that form:
mailform.etemp
- Used to create the formatted email message.
mailform.phtml
- Shown after successful post.
no_name.phtml
- Shown when no name is entered.
no_email.phtml
- Shown when no email or an invalid email is entered.
no_url.phtml
- Shown when no URL or an invalid URL is entered.
no_cc.phtml
- Shown when no credit card number or an invalid number is entered.
Synopsis:
The FORM tag must be as follows:
either
<FORM ACTION="/cgi-bin/mail"
METHOD="POST">
or
<FORM ACTION="/cgi-bin/mail"
METHOD="GET">
All variables must be defined in your form in one of three ways:
Input Type Hidden - This allows you to embed values
into your form that don't change.
<input type="hidden"
name="VARIABLE" value="VALUE">
Input Type Text - This inserts an input box which allows
the user of the form to specify the value of the variable.
<input type="text"
name="VARIABLE">
Select - This inserts a drop-down menu that allows the
user to choose from a list.
<select name="VARIABLE">
<option>
Option 1
<option>
Another option
</select>
Variables:
to (required)
Must be set to the
destination email address to which contents of the form should be sent.
cc
Any additional email
addresses to which the email message should be sent.
next
The URL or file
that will be the "next hop" after the form is submitted. This
can either be a URL (starting with http://...), or a local HTML file
with or without subcodes. This file should be specified with either
its full path (/users/j/johndoe/www/whatever.phtml) or by the full path
starting from the DocumentRoot directory of your Virtual Server. For
instance, if your Virtual Server points to /users/j/johndoe/www/domain,
and your file were located in /users/j/johndoe/www/domain/dir/file.phtml,
then you would specify "/dir/file.phtml" as the value of this
variable.
If a file is specified, the file is parsed and the values of the other
variables in the form may be inserted in the file before output using
an advanced parsing engine. See the mail
system manual page for details.
If a URL is specified, no parsing is possible. If a file is specified,
make sure you use absolute links within it.
If not specified, mail will present a default page that says "Message
Sent" and has a link that points to the root of the Virtual Server
on which the form was located.
emailtemplate
File to be used
as a template to construct the outbound email message. Data from the
form can be inserted using subcodes (just like the file specified by
next). For more info on the parsing engine and how subcodes work, see
the mail
systeam manual page. This file starts in the header of the email
message. This means that the first line of the file is a mail header.
The mail header continues until the first blank line. There must be
a blank line to separate the header from the body. Typically, The first
line would be just the Subject: header. So a template file would start
off with a line that reads:
Subject: ${subject}
followed by a blank line. Do not forget to have a blank line after the
headers. If you do, your message will fail.
subject
The subject of the
form. The value of this variable is used in the subject line of the
generated email message if you don't use an email template.
confirm
A return (origin)
email address, and a file to be used as a template to send an email
message to the person filling out the form at the address he/she supplies
in the "email" field of the form. The template used follows
the exact same parsing conventions as that specified by the "emailtemplate"
variable.
pgp
Value is of the
form: username; keyid
Consists of a username, a semi-colon, and a PGP User ID. The username
tells PGP whose public keyring to search. The PGP User ID tells PGP
what public key to find in the keyring. The public key is then used
to encrypt the body of the email message, which may then only be decrypted
by the person(s) holding the corresponding private (secret) key. This
encryption allows for the sending of highly sensitive information via
email, such as personal and financial information typically accompanying
product/service orders.
name
The name of the
person submitting the form. This variable would typically be set using
an input box of type text, allowing the submitter to enter their name.
It is used to set the name of the sender on the outbound email message.
email
The email address
of the person submitting the form. This variable would typically be
set using an input box of type text, allowing the submitter to enter
their email address. It is used to set the email address of the sender
on the outbound email message so that the message can be replied to.
require
Value is of the
form: variable
variable; file
A require rule tells mail not to send any mail if any of the variables
listed before the semicolon do not contain any data. If the rule is
not satisfied, the file or URL specified after the semicolon is sent
instead.
is_email
Value is of the
form: variable
variable; file
An is_email rule tells mail not to send any mail if any of the variables
listed before the semicolon do not contain properly formatted Internet
email addresses. If the rule is not satisfied, the file or URL specified
after the semicolon is sent instead.
is_web
Value is of the
form: variable
variable; file
An is_web rule tells mail not to send any mail if any of the variables
listed before the semicolon do not contain properly formatted WWW addresses.
If the rule is not satisfied, the file or URL specified after the semicolon
is sent instead.
is_ccard
Value is of the
form: variable
variable; file
An is_ccard rule tells mail not to send any mail if any of the variables
listed before the semicolon do not contain a credit card number that
passes standard mathematical checksums. This does NOT check to see if
the card is active or even exists. Rather, it just checks to see if
the number can be used as a valid credit card number. If the rule is
not satisfied, the file or URL specified after the semicolon is sent
instead.
bgprocess
The URL of another
script to which the contents of the form should be posted. This allows
you to have the contents of a form mailed to you AND processed by your
own script without requiring the user to fillin two forms. To protect
against loops, the name of the bgprocess variable is changed to "_bgprocess"
before the post is done. Method POST is always used regardless of how
the mail script was originally called. The repost is done in the background,
and the reponse from the specified script is discarded.
fgprocess
The URL of another
script to which the contents of the form should be posted. This allows
you to have the contents of a form mailed to you AND processed by your
own script without requiring the user to fillin two forms. To protect
against loops, the name of the fgprocess variable is changed to "_fgprocess"
before the post is done. Method POST is always used regardless of how
the mail script was originally called. The repost is done in the foreground,
and the response from the specified script is sent directly to the browser,
as if the mail script generated it. When fgprocess is used and a valid
URL is specified, the next variable is completely ignored.
|