DevPortal

How do I configure Mail Resources for J2EE Applications?


Table of Contents


What are Mail Resources used for?

Mail Resources are used to send mails from within the code using the mail session object.

How do I use resource-config.xml to create Mail Resources?

You can configure a Mail Resource using resource-config.xml by adding a mail-resource tag under the mail-resources tag. The resource-config.xml looks as below:

<?xml version="1.0" encoding="UTF-8"?>
<DOCTYPE resource-service PUBLIC '-//Pramati Technologies //DTD Pramati Resource Service//EN'
'http://www.pramati.com/dtd/pramati-resource-service.dtd'>
<resource-service>
<resources>
<default-resources> <default-resources>
<datasources> <datasources>
<connection-factories> <connection-factories>
<mail-resources>
<mail-resource name="myMailResource" host="mail.pramati.com" description="No Description">
<login-parameters id="Test" user="test" password="test" mask-password="false" />
      <mail-resource>
</mail-resources>
<url-resources> <url-resources>
<jms-adapters> <jms-adapters>
</resources>
<resource-service>

How do I use Resource Shell to create Mail Resources?

To add a Mail Resource using the resource shell, on the resourceadmin:> prompt, enter resourceadmin:> add_mailresource. Following are the two ways to add a Mail Resource:

Interactive

To use the interactive mode, enter add_mailresource, and press Enter. This asks for all the required fields one after the other. No special flag is required for this mode. Enter the following values needed for the command resourceadmin:> add_mailresource.

resourceadmin>  - jndi name * #myMailer
resourceadmin>  - host name * #mail.pramati.com
resourceadmin>  - mailID * #Test
resourceadmin>  - user * #test
resourceadmin>  - password * #test
Creating MailResource myMailer
Mail Resource [myMailer] started
Created MailResource myMailer successfully
Added Mail resource [myMailer]

Note: Fields followed by * are mandatory. Press Enter for default values. Typing 'q' and pressing Enter at any point cancels the current command.

Non-Interactive

To use the non-interactive mode, enter add_mailresource. All the required attributes - the jndiName, hostName, mailID, user, and password in this case, have to be specified. All optional attributes have default values that can be modified.

There are three ways in which you can specify the fields:

How do I use Mail Resource MBeans to create Mail Resources?

Once you have the Resource Service MBean, get the Mail Resource MBean by entering:

MailResourceServiceMBean mailresource = resourceServiceMBean.getMailResourceServiceMBean();
Call the createMailResource method on this MBean. The details of the parameters used in the MBean are as follows:
public void createMailResource(String jndiName, String hostName, String mailID,
String userName, String password) throws ResourceException

How do I use the Console to create Mail Resources?

To configure a Mail Resource on the Console, select Configure > Resources. This displays the Resources screen. If there are Mail Resources added earlier, the following details are displayed:

Table 1: Mail Resource details

FieldsDescription
NameThe JNDI name of the Mail Resource. This is a mandatory field and must be unique.
HostThis provides the IP address of the machine/host where the mail server is located/running.
IDThe mailing address, for example john@pramati.com.
PropertiesUse Edit provided to modify and view the existing properties for the Mail Resource.
AddUse Add to add a new Mail Resource
DeleteUse Delete to delete a Mail Resource after you have selected it using the check box provided.

How do I add Mail Resources?

To add a Mail Resource, click Add under the Mail Resources section, and specify the following information:

Table 2: Details for adding a Mail Resource

FieldsDescription
NameEnter here a unique name with which the Mail Resource gets bound in Server. This is a mandatory field.
HostProvides the IP address of the machine/host where the mail server is located/running. This is a mandatory field.
IDEnter a valid e-mail address where the mail is to be sent. This is a mandatory field.
UsernameEnter here the user name that allows a user with the given e-mail address to connect to mail server.
PasswordEnter here the password required to authenticate the user name.

There is no Resource Pool Information for Mail Resources because they are not pooled. When you click Save to add a new Mail Resource, Console sends out a test mail to the e-mail address supplied earlier to ensure that the values provided are correct.

If a mail is sent successfully, a success message is displayed. All mails sent using this Mail Resource will have the From field's value as that specified in the ID field.

How do I edit Mail Resources?

Mail Resources once created cannot be modified in Server. To modify a Mail Resource, you need to delete it and recreate the resource.

How do I delete Mail Resources?

Select the Mail Resource to be deleted using the check box on the Resources page and click Delete. This deletes the selected Mail Resource.


Related Topics:

© Pramati Technologies 2007 Runs on Pramati Server | Feedback | Legal