WmlMail servlet 1.9

    It is a Java servlet allows you to send email from WAP phone or any another PDA supports WML. With this servlet you may simulate for example HTML's tag mailto:

    How does it work? You have to create a text template for your mail and pass this file as a parameter for servlet. You may have more than one template of course. Servlet will read mail settings from such template and detect what kind of parameters do we need to ask from the user in the dialogue. For example you may decide to use some static subject for the letter or servlet will ask user to type this information etc.

    The typical scenario for your WML portal is: suppose you need to give your users the ability to send some file (e.g. price list, contact agreement etc.) from WML page. Just create a text file describes mail host, port, subject, source(from) address and the path to attached file. Destination address will be asked in the dialogue. Add to your WML page the following link:
 


<a href="http://your_host/servlet/WmlMailServlet?your_template_file">Send price list</a>

and your users will be able to activate this mail right from the phone.

    How to use it:

a) copy wmlMailPackage.jar into WEB-INF/lib directory

b) describe servlet in your web.xml file:
 


    <servlet>
     <servlet-name>WmlMailServlet</servlet-name>
     <servlet-class>com.jsos.wmlmail.WmlMailServlet</servlet-class>
    </servlet>

You can pass template file as a parameter to this servlet and use it in this form:
 


    http://your_host/servlet/WmlMailServlet?template_file

or you may describe template file as an initial parameter (parameter name is config):
 


    <servlet>
     <servlet-name>WmlMailServlet</servlet-name>
     <servlet-class>com.jsos.wmlmail.WmlMailServlet</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/WmlMailServlet

    Template file is a text describes mail settings and template for mail.  In this file you can set address of your smtp relay, smtp port, domain and describe contents for your letter. Appropriate WML form will be composed dynamically according to settings in the template file.

    When you describe your letter you can use meta-variables: $from, $to, $subject, $body. These variables will be replaced by the appropriate field value from the submitted form. Letter will be also composed dynamically, when you submit form in WML. You can also attach some files saved on your server (e.g. price list from your company, your resume etc.)
    Template file has got free format, but description of any parameter must starts with the appropriate reserved word on the new line.
    Current version supports the following list of parameters:

    Mailhost: describes your smtp host. This parameter is mandatory
    Port: describes smtp port. By default it is 25.
    Domain: describes your domain. This parameter is mandatory
    From: describes source address.
    To: describes destination address.
    Subject: set letter's subject
    Body: set letters body
    Attach: you can set here a list of files you want to be attached to the composed letter.
    After: you can set here an URL for some WML page user will jump to after mail sending.
    Encoding: character encoding for input parameters. Default value is ISO-8859-1
    Html: describes format. Possible values are true or false. If this value if true servlet will send letter in HTML format. Default value is false.

E.g. the simplest configuration file is:
 


Mailhost:smtp.your_company.com
Domain:your_company.com
Port:25
From:$from
To:$to
Subject:$subject
Body:$body
After:/index.wml

Another example: for some Short Message service you can describe field To as
 


To:$to@acme.com

and type only the first part of address ($to) (e.g. phone number) in the generated mail form. You can set also constant value for any field:
 

To:support@your_company.com

In this case that field will be omitted in the generated WML form.

    When you describe body field you can use also construction like:
    $file=path_to_some_text_file
    Content of this file will be added to the body of composed letter.

    When you set attachments  you can use list of files. Files should be separated by commas.

Note:
1. Configuration file can be saved anywhere on your server. In case of usage
WmlMail?file_name we assume that this file is saved under the root (docBase) directory of your servletrunner. But you can always use the full path for setting file's location. E.g. you can type some like:
http://your_host/servlet/WmlMailServlet?c:\myfiles\myconfig.txt
or
http://your_host/servlet/WmlMailServlet?/home/users/me/myconfig.txt

    For downloading:  wmlMailPackage.jar   
    Sample of configuration file:  wmlconf
 

  © Coldbeans Software     Comments?

See also JSOS - the largest collection of servlets and filters.