JavaMail Sample Application

JavaMail Sample Application


This document describes how to use the JavaMail sample application with the Sun Java System Web Server.

This document contains the following sections:


Overview

This simple JavaMail sample application demonstrates how to use the JavaMail API. The application uses a servlet to send an email message.


Compiling and Assembling the Application


To compile and assemble the sample application, complete the following steps:

  1. Make sure the necessary parameters for running the samples are specified in install_root/samples/java/webapps/common.properties and
    the necessary parameters for creating the JavaMail resource are specified in
    install_root/samples/java/webapps/javamail/src/javamail.build.properties.

  2. Compile and assemble the WAR file by changing to the source directory at install_root/samples/java/webapps/javamail/src and running the ant command.

    The default target default is executed to build the WAR file.
  3. Run the following command to create the mail resource:

    # ant create_javamail

    To run this command successfully, Administration Server must be running, and necessary parameters such as config.name, vs.name,
    passwordfile.path etc. in
    install_root/samples/java/webapps/common.properties file must be specified correctly. (See 1. above)
  4. Deploy the application.

    After you have created the sample application from scratch, you can proceed to Deploying the Sample Application.

  5. (Optional.) Clean the web application project area.

    # ant clean

Deploying the Sample Application

To deploy the sample application, complete the following steps:
  1. Change to the source directory at install_root/samples/java/webapps/javamail/src.

  2. Run the ant tool using the deploy task.

    # ant deploy
If you want to verify registration of the application, proceed to Verifying Deployment. Otherwise, proceed to Running the Sample Application.
 

Verifying Deployment

To verify the registration and deployment of the application, complete the following steps:

  1. Change to the source directory at install_root/samples/java/webapps/javamail/src.

  2. Run the ant tool using the list_apps task.

    # ant list_apps

    The javamail module is listed as one of the components.


Running the Sample Application



You can run the application through the following URL:

http://Sun_Java_System_Web_Server_hostname:port/javamail/sendmail.jsp

Undeploying the Sample Application


After successfully deploying and running the application, you might decide to undeploy it and remove the files. To undeploy the application, complete the following steps:  

  1. Change to the source directory at install_root/samples/java/webapps/javamail/src.

  2. Run the ant tool using the undeploy task.

    # ant undeploy

    This removes the JavaMail sample.

  3. Run the ant tool using the delete_resource task.

    # ant delete_resource

     
    This removes the deployed mail resource.


Copyright © 2007 Sun Microsystems, Inc. All rights reserved.