![]() |
|
Mail Resources are used to send mails from within the code using the mail session object.
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>
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:
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.
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:
add_mailresource jndiName=myMailResource hostName=mail.pramati.com mailID=Test user=test password=testadd_mailresource myMailResource mail.pramati.com Test test testadd_mailresource -jndiName myMailResource -hostName mail.pramati.com -mailID Test -user test -password testOnce 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
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
| Fields | Description |
|---|---|
| Name | The JNDI name of the Mail Resource. This is a mandatory field and must be unique. |
| Host | This provides the IP address of the machine/host where the mail server is located/running. |
| ID | The mailing address, for example john@pramati.com. |
| Properties | Use Edit provided to modify and view the existing properties for the Mail Resource. |
| Add | Use Add to add a new Mail Resource |
| Delete | Use Delete to delete a Mail Resource after you have selected it using the check box provided. |
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
| Fields | Description |
|---|---|
| Name | Enter here a unique name with which the Mail Resource gets bound in Server. This is a mandatory field. |
| Host | Provides the IP address of the machine/host where the mail server is located/running. This is a mandatory field. |
| ID | Enter a valid e-mail address where the mail is to be sent. This is a mandatory field. |
| Username | Enter here the user name that allows a user with the given e-mail address to connect to mail server. |
| Password | Enter 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.
Mail Resources once created cannot be modified in Server. To modify a Mail Resource, you need to delete it and recreate the resource.
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 |