The mail service is an optional service that may be used to send emails.
It is based on JavaMail and on JavaBeans Activation Framework (JAF) API.The default implementation of the mail service rely on the GNUMail implementation of these API.
A mail factory is required in order to send or receive mails. JOnAS
provides two types of mail factories:
javax.mail.Session
and
javax.mail.internet.MimePartDataSource
.
MimePartDataSource
factories allow mail to be sent
with a subject and the recipients already set.
Mail factory objects must be configured according to their type. The
subsections that follow briefly describe how to configure
Session
and MimePartDataSource
mail factory objects, in order to run the SessionMailer SessionBean and the
MimePartDSMailer SessionBean delivered with the platform.
Here is the part of jonas.properties
concerning
the mail service:
###################### JOnAS Mail service configuration # # Set the name of the implementation class of the mail service jonas.service.mail.class org.ow2.jonas.mail.internal.JOnASMailService # Set the jonas mail factories. # This property is set with a coma-separated list of MailFactory properties # file names (without the '.properties' suffix). # Ex: MailSession1,MailMimePartDS1 (while the properties file names are # MailSession1.properties and MailMimePartDS1.properties) jonas.service.mail.factories
Mail factory objects created by JOnAS must be
given a name. For example, consider two factories called
MailSession1
and MailMimePartDS1
. Each
factory must have a configuration file whose name is the name of the factory
with the .properties
extension
(MailSession1.properties
for the MailSession1
factory).
For this example jonas.service.mail.factories property must be set to:
jonas.service.mail.factories MailSession1,MailMimePartDS1
A template MailSession1.properties
file is
supplied in $JONAS_BASE/conf.
It
contains two mandatory properties :
#Factory Name/Type mail.factory.name mailSession_1 mail.factory.type javax.mail.Session
The JNDI name of the mail factory object is mailSession_1. This template must be updated with values appropriate to your installation. See the section "Configuring a mail factory" below for the list of available properties.
A template MimePartDS1.properties
is supplied
in $JONAS_BASE/conf
. It contains
two mandatory properties :
#Factory Name/Type mail.factory.name mailMimePartDS_1 mail.factory.type javax.mail.internet.MimePartDataSource
The JNDI name of the mail factory object is mailMimePartDS_1. This template must be updated with values appropriate to your installation. See the section "Configuring a mail factory" below for the list of available properties.
Here are the possible properties
Required properties:
Property name | Description |
mail.factory.name | JNDI name of the mail factory |
mail.factory.type | The type of the factory. This property can be javax.mail.Session or javax.mail.internet.MimePartDataSource. |
Optional properties: Authentication properties
Property name | Description |
mail.authentication.username | Set the username for the authentication. |
mail.authentication.password | Set the password for the authentication. |
Optional properties: javax.mail.Session.properties (refer to JavaMail documentation for more information)
Property name | Description |
mail.debug | The initial debug mode. Default is false. |
mail.from | The return email address of the current user, used by the InternetAddress method getLocalAddress. |
mail.mime.address.strict | The MimeMessage class uses the InternetAddress method parseHeader to parse headers in messages. This property controls the strict flag passed to the parseHeader method. The default is true. |
mail.host | The default host name of the mail server for both Stores and Transports. Used if the mail.protocol.host property is not set. |
mail.store.protocol | Specifies the default message access protocol. The Session method getStore() returns a Store object that implements this protocol. By default the first Store provider in the configuration files is returned. |
mail.transport.protocol | Specifies the default message access protocol. The Session method getTransport() returns a Transport object that implements this protocol. By default, the first Transport provider in the configuration files is returned. |
mail.user | The default user name to use when connecting to the mail server. Used if the mail.protocol.user property is not set. |
mail.<protocol>.class | Specifies the fully- qualified class name of the provider for the specified protocol. Used in cases where more than one provider for a given protocol exists; this property can be used to specify which provider to use by default. The provider must still be listed in a configuration file. |
mail.<protocol>.host | The host name of the mail server for the specified protocol. Overrides the mail.host property. |
mail.<protocol>.port | The port number of the mail server for the specified protocol. If not specified, the protocol's default port number is used. |
mail.<protocol>.user | The user name to use when connecting to mail servers using the specified protocol. Overrides the mail.user property. |
Optional properties:MimePartDataSource properties (Only used if mail.factory.type is javax.mail.internet.MimePartDataSource)
Property name | Description |
mail.to | Set the list of primary recipients ("to") of the message. |
mail.cc | Set the list of Carbon Copy recipients ("cc") of the message. mail.bcc |
mail.bcc | Set the list of Blind Carbon Copy recipients ("bcc") of the message. |
mail.subject | Set the subject of the message. |