mail-resource
Defines a JavaMail
(javax.mail.Session) resource.
Superelements
resources (sun-resources.xml)
Subelements
The following table describes subelements for the mail-resource element.
Table C–83
mail-resource
Subelements
Attributes
The following table describes attributes for the mail-resource element.
Table C–84
mail-resource
Attributes
Attribute
|
Default
|
Description
|
jndi-name
|
none
|
Specifies the JNDI name for the resource.
|
store-protocol
|
imap
|
(optional) Specifies the storage protocol service, which connects
to a mail server, retrieves messages, and saves messages in folder(s).
Allowed values are imap, pop3, imaps, and pop3s .
|
store-protocol-class
|
com.sun.mail.imap.IMAPStore
|
(optional) Specifies the service provider implementation class
for storage. Allowed values are:
com.sun.mail.imap.IMAPStore
com.sun.mail.pop3.POP3Store
com.sun.mail.imap.IMAPSSLStore
com.sun.mail.pop3.POP3SSLStore
|
transport-protocol
|
smtp
|
(optional) Specifies the transport protocol service, which sends
messages. Allowed values are smtp and smtps.
|
transport-protocol-class
|
com.sun.mail.smtp.SMTPTransport
|
(optional) Specifies the service provider implementation class
for transport. Allowed values are:
com.sun.mail.smtp.SMTPTransport
com.sun.mail.smtp.SMTPSSLTransport
|
host
|
none
|
The mail server host name.
|
user
|
none
|
The mail server user name.
|
from
|
none
|
The email address the mail server uses to indicate the message
sender.
|
debug
|
false
|
(optional) Determines whether debugging for this resource is
enabled.
|
object-type
|
user
|
(optional) Defines the type of the resource. Allowed values
are:
-
system-all - A system resource
for all server instances and the domain application server.
-
system-admin - A system resource
only for the domain application server.
-
system-instance - A system resource
for all server instances only.
-
user - A user resource.
|
enabled
|
true
|
(optional) Determines whether this resource is enabled at runtime.
|
Properties
You can set properties for the mail-resource element
and then get these properties in a JavaMail Session object
later. Every property name must start with a mail- prefix.
The GlassFish Server changes the dash (-) character
to a period (.) in the name of the property, then
saves the property to the MailConfiguration and
JavaMail Session objects. If the name of the
property doesn’t start with mail-, the property
is ignored.
For example, to define the property mail.password in
a JavaMail Session object, first edit sun-resources.xml as
follows:
...
<mail-resource jndi-name="mail/Session" ...>
<property name="mail-password" value="adminadmin"/>
</mail-resource>
...
After getting the JavaMail Session object,
get the mail.password property to retrieve the
value adminadmin, as follows:
String password = session.getProperty("mail.password");
For more information about JavaMail properties, see JavaMail API Documentation.