WebLogic Server 7.0 Code Examples, BEA Systems, Inc.

Package examples.javamail

This example illustrates how to use javamail with WebLogic Server.

See:
          Description

Class Summary
MailServlet This example servlet takes input from a html form, and calls the SendMail class based on it.
SendMessage This example SendMessage class simply invokes the javax.mail classes, and sends a message blindly passing the strings passed to it.
 

Package examples.javamail Description

This example illustrates how to use javamail with WebLogic Server. It demonstrates:

Additional Resources for examples.javamail
MailExample.html The html form page that calls the MailServlet.
build.xml The Java Ant build script assembles and deploys the application.

The following sections describe how to build and run the example:

  1. Build the Example
  2. Configure the Server
  3. Run the Example

Build the Example

Set up your development shell as described in Setting up your environment.

The following build script is provided for you to build the example: build.xml

Run the build script using the following Java ant command:

prompt> ant
The script will build the example and place the files in the correct locations in your WebLogic Server distribution: You can find additional information on using the build scripts in More About Building Examples.
 

Configure the Server

The following procedure shows how to configure javamail on WebLogic Server:
  1. Start WebLogic Server.
  2. Start the Administration Console.
  3. Click on the Mail node in the left pane, and select "Configure a new Mail Session..."
  4. In the JNDI name field, enter "MyMail Session". This is the session specified in the SendMessage class.
  5. In the Properties text area, enter javamail properties for mail.host and mail.user. The text area should look similar to the following:
  6. mail.host=mail.mycompany.com
    mail.user=joe
  7. If you want to turn on debug information, add the following to the Properties text area:
  8. mail.debug=true
    For more information on javamail properties, see Using JavaMail with WebLogic Server Applications.
     
  9. Click Create.
  10. Click Apply.
  11. Click on the Targets tab, choose the examplesServer, and apply the selection.

Run the Example

  1. Use a Web browser to load the following URL:
  2. http://WebLogicURL:WebLogicPort/examplesWebApp/MailExample.html
    For example, the following illustrates how you load the servlet in a browser running on the same NT host as your WebLogic Server on port 7001:
    http://localhost:7001/examplesWebApp/MailExample.html
    
    
    If the servlet executes correctly you will see "Your message has been sent" in the browser.

See Also


Documentation is available at
http://e-docs.bea.com/wls/docs70

Copyright © 2002 BEA Systems, Inc. All Rights Reserved.