|
This shared e-mail servlet provides an easy way for your site to send the contents of
a web form to an e-mail address. MailServlet is already installed and available for your
site to use.
To use MailServlet, a form should use the POST method and call the MailServlet in the
ACTION tag. Here is an example FORM tag:
<FORM ACTION="http://www.<yourserver>.com/servlet/net.servlets.util.MailServlet" METHOD="POST">
The form MUST have the following fields. These fields can be hidden if desired:
- 1. host
- This is the mail server to use, such as mail.yourserver.com or mail.servlets.net. This field must exist and must be a valid mail server.
<input type="Hidden" name="host" value="mail.yourserver.com">
- 2. to
- The email address that is used in the TO field of the email. The form contents will get sent to this address. Only one email address may be used in this field. This field must exist and must be a valid email address.
<input type="Hidden" name="to" value="youremail@yourserver.com">
- 3. cc
- Another email address that is used in the CC field of the email. Only one email address may be used in this field. This field must exist, but it can be an empty string.
<input type="Hidden" name="cc" value="">
- 4. bcc
- Another email address that is used in the BCC field of the email. Only one email address may be used in this field. This field must exist, but it can be an empty string.
<input type="Hidden" name="bcc" value="">
- 5. from
- The email address that is used in the FROM field of the email. The email will be sent from this address. Only one email address may be used in this field. Because many mail servers (including all Servlets.Net servers) have anti-spam/anti-relay filters, this address must be an address from your domain (such as webmaster@yourserver.com). Do not use this field as an input field in the form for the user to enter their email address or the mail server will reject the mail. This field must exist and must be a valid email address.
<input type="hidden" name="from" value="webmaster@yourserver.com">
- 6. subject
- The subject line of the email. This field must exist, but it can be an empty string.
<input type="Hidden" name="subject" value="Feedback Form">
- 7. name
- A full name for the person submitting the form. This field must exist, but it can be an empty string.
<input type="Text" name="name" value="" size="40" maxlength="40">
- 8. url
- URL to display if the email is sent successfully. This field must exist and must be a valid fully qualified web address.
<input type="Hidden" name="url" value="http://www.yourserver.com/redirect/success/to/here.html">
- 9. errorurl
- URL to display if the email is not sent successfully. This field must exist and must be a valid fully qualified web address.
<input type="Hidden" name="errorurl" value="http://www.yourserver.com/redirect/failure/to/here.html">
- 10. fields
- The fields to display in the email and the order to display them. This allows you to control the fields that will get displayed in the email and the order in which they are displayed. Field names should be separated with commas. There should be no white space between the field names and commas. This field must exist, but it can be an empty string.
<input type="Hidden" name="fields" value="name,subject,body">
As many other fields as you wish may be included in the form. To have the contents of a form field appear in the email, it must be included in the comma delimited list of fields in the "fields" field. For example, you may wish to collect a user's email address in a field named "email". The word email would need to be included in the value of the "fields" field.
Here is an example HTML document:
<html>
<head>
<title>Feedback Form</title>
</head>
<body>
<form action="http://www.yourserver.com/servlet/net.servlets.util.MailServlet" method="POST">
<input type="Hidden" name="fields" value="name,email,subject,body">
<input type="Hidden" name="to" value="youremail@yourserver.com">
<input type="Hidden" name="subject" value="Feedback Form">
<input type="Hidden" name="cc" value="">
<input type="Hidden" name="bcc" value="">
<input type="Hidden" name="host" value="mail.yourserver.com">
<input type="Hidden" name="url" value="http://www.yourserver.com/redirect/success/to/here.html">
<input type="Hidden" name="errorurl" value="http://www.yourserver.com/redirect/failure/to/here.html">
<input type="hidden" name="from" value="webmaster@yourserver.com">
Name: <input type="Text" name="name" value="" size="40" maxlength="40"><br>
Email: <input type="Text" name="email" value="" size="40" maxlength="40"><br><br>
Message:<br>
<textarea name="body" cols="40" rows="10" wrap="VIRTUAL"></textarea><br>
<input type="Submit" name="send" value="Send">
</form>
</body>
</html>
|