![]() |
JavaMail Sample Application |
JavaMail Sample Application
This document describes how to use the JavaMail sample application in conjunction with Sun ONE Web Server.This sample application document contains the following sections:
Overview
Overview- Compiling and Assembling the Application
- Deploying the Sample Application
- Running the Sample Application
This simple JavaMail sample application demonstrates use of the JavaMail API. The application uses a servlet to send an e-mail.Compiling and Assembling the Application
To compile and assemble the sample application, perform the following steps:
Change it from this:(d) Restart the web server instance.
<JAVA javahome="/ws61/bin/https/jdk" serverclasspath="/ws61/bin/https/jar/webserv-rt.jar: ${java.home}/lib/tools.jar:/ws61/bin/https/jar/webserv-ext.jar:/ws61/bin/https/jar/webserv-jstl.jar: /ws61/bin/https/jar/ktsearch.jar" classpathsuffix="" envclasspathignored="on" debug="false" debugoptions="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n" dynamicreloadinterval="2"> ........ ........ </JAVA> to this: <JAVA javahome="/ws61/bin/https/jdk" serverclasspath="/ws61/bin/https/jar/webserv-rt.jar:${java.home}/lib/tools.jar: /ws61/bin/https/jar/webserv-ext.jar:/ws61/bin/https/jar/webserv-jstl.jar: /ws61/bin/https/jar/ktsearch.jar" classpathsuffix="/ws61/bin/https/jar/mail.jar:/ws61/bin/https/jar/activation.jar" envclasspathignored="on" debug="false" debugoptions="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n" dynamicreloadinterval="2"> ........ ........ </JAVA>
Make sure the necessary
parameters for creating the JavaMail resource are specified in the build.xml file as
follows:
<!--
======================================================= -->
<!-- MAILRESOURCE
properties
-->
<!--
======================================================= -->
<property name="javamail.resource.jndiname"
value="mail/Session"/>
<property
name="javamail.resource.host"
value="localhost"/>
<property
name="javamail.resource.user"
value="nobody"/>
<property
name="javamail.resource.from"
value="xyz@foo.com"/>
<property
name="javamail.resource.enabled"
value="true"/>
The default target 'default' will be executed to build the WAR file.
ant
create_javamail
Then restart the web server instance.
Note: The following
values are hard coded. If you want to change them, modify the common.xml file under the <install_root>/plugins/java/samples/webapps
directory.
storeprotocol = imap
storeprotocolclass =
com.sun.mail.imap.IMAPStore
transportprotocol =
smtp
transportprotocolclass = com.sun.mail.smtp.SMTPTransport
Deploy the application.
After you have created the
sample application from scratch, you can proceed to Deploying
the Sample Application. Step 6 is optional.
To clean the web application project area (optional), execute the following command:
As an optional step, you can verify that the application has been registered. Otherwise, proceed directly to Running the Sample Application.
Running the Sample
Application
http://<Web_Server_hostname>:<port>/javamail/sendmail.jsp
Copyright © 2003 Sun Microsystems, Inc. All rights reserved.