It is a Java servlet allows you to email any html forms. You must set this servlet as an action parameter for your form. Servlet collects posted data and processes them according to own configuration file. Configuration file (or template file) describes how your mail looks like, what is your smtp server etc. How to use it: a) copy formMailPackage.jar into WEB-INF/lib directory b) describe servlet in your web.xml file:
<servlet> <servlet-name>FormMailServlet</servlet-name> <servlet-class>com.jsos.formmail.FormMailServlet</servlet-class> </servlet> You can pass template file as a parameter to this servlet and use it
in this form:
http://your_host/servlet/FormMailServlet?template_file E.g.:
<form method=post action="http://your_host/servlet/FormMailServlet?c:\template1.txt"> To:<input type=text name=to><br> Subj:<input type=text name=subj><br> <textarea rows=5 cols=30 name=body> </textarea><br> <input type=submit value=Send> </form> or you may describe template file as an initial parameter (parameter name is config):
<servlet> <servlet-name>FormMailServlet</servlet-name> <servlet-class>com.jsos.formmail.FormMailServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>path_to_your_template_file</param-value> </init-param> </servlet> and use servlet in this form:
http://your_host/servlet/FormMailServlet E.g.:
<form method=post action="http://your_host/servlet/FormMailServlet">
Template file describes mail your settings as well as a template
for your mail. Template file is a text file. In this file you can
set address of your smtp relay, smtp port, domain and describe contents
of the letter. When you describe contents you can use values of fields from your form.
Letter will be composed dynamically, when you submit this form.
Mailhost: describes your smtp host.
This parameter is mandatory
When you describe contents of any field in your configuration
file, you can use constructions like $FormFieldName as a reference for the value of the
appropriate form's field. E.g. for the above mentioned example you can
set some like this:
here $to will be replaced with the actual value for the
field named to in the submitted form, $subj will
be replaced with the value of field named subj etc.
When you set attachments you can use a list of files. Files should be separated by commas. Notes: 1. Servlet's configuration file can be saved anywhere on your server. E.g. if you are using FormMailServlet?config line we assume this file is saved under the root directory of your servletrunner. But you can of course always use the full path for setting config file location: FormMailServlet?/home/users/my_file (or FormMailServlet?c:\users\my_file) 2. If reply value starts with
http than request will be redirected to that site. Otherwise servlet assumes
a local resource and forwards request.
For downloading: formMailPackage.jar
See also JSOS - the largest collection of servlets and filters.
|
Also in JSOS:
|