Home > Documentation > Sample applications > Using Geronimo's default JavaMail session |
This was tested on trunk and should be the same steps for Geronimo v1.2 and v2.0 with minor changes specifically references to JavaMail module ID.
1. Download Apache JAMES from: http://apache2.openmirrors.org/james/server/binaries/james-2.3.0.zip
2. Unzip file and run JAMES by executing: \james-2.3.0\bin\run.bat. You should see something like this:
3. Make sure JavaMail module is started:
a. Use the Web Console: Applications > System Modules > Click 'Start' link beside the JavaMail module ID
b. Use command line deployer:
c. Stop the server. Modify <geronimo_home>\var\config\config.xml and set JavaMail module load attribute to 'true':
You can configure the SMTP transport's host and port by overriding the values of the SMTPTransport GBean attrbitues. For our test we will use the default. This will allow us to connect to JAMES running in localhost and using port 25 (the default SMTP port).
Create a simple webapp containing the following files:
web.xml:
geronimo-web.xml: This deployable is using Geronimo 2.0's JavaMail component, so it needs to specify where to look. It does this under the <dependencies> tag. As Geronimo changes, these paths need to be changed accordingly to ensure that it refers to the same things. Under the <resource-ref> element, it is referring to a JavaMail session. This is what allows the developer to reference resources that resides on the server. The <ref-name> element is used in the web.xml so the two must be consistent. The <resource-link> element specifies the default Geronimo mail session.
index.jsp:
Download the sendmail application from the following link:
sendmail
After decompressing the given file, the sendmail directory will be created.
You can checkout the source code of this sample from SVN:
svn checkout http://svn.apache.org/repos/asf/geronimo/samples/trunk/samples/sendmail
The sendmail folder will already contain an ear file ready to be deployed. However, you can still play with the source and build it yourself.
Use a command prompt to navigate into the sendmail directory and just give mvn install site command to build. It will overwrite the sendmail-ear-2.0-SNAPSHOT.ear under the sendmail folder.
5. Test send mail webapp by going to: http://localhost:8080/sendmail
Fill up the form (From, To, Subject, Message fields) and click 'Send' button. You should get a similar message if the mail was sent successfully:
Bookmark this on Delicious Digg this | Privacy Policy - Copyright © 2003-2009, The Apache Software Foundation, Licensed under ASL 2.0. |