type=page
status=published
title=create-javamail-resource
next=create-jdbc-connection-pool.html
prev=create-jacc-provider.html
~~~~~~

= create-javamail-resource

[[create-javamail-resource-1]][[GSRFM00035]][[create-javamail-resource]]

== create-javamail-resource

Creates a JavaMail session resource

[[sthref312]]

=== Synopsis

[source]
----
asadmin [asadmin-options] create-javamail-resource [--help]
[--target target] --mailhost hostname
--mailuser username --fromaddress address [--storeprotocol storeprotocol]
[--storeprotocolclass storeprotocolclass] [--transprotocol transprotocol]
[--transprotocolclass transprotocolclass] [--debug={false|true}] [--enabled={true|false}]
[--description resource-description] [--property (name=value)[:name=value]*] jndi-name
----

[[sthref313]]

=== Description

The `create-javamail-resource` subcommand creates a JavaMail session
resource.

This subcommand is supported in remote mode only.

[[sthref314]]

=== Options

asadmin-options::
  Options for the `asadmin` utility. For information about these
  options, see the link:asadmin.html#asadmin-1m[`asadmin`(1M)] help page.
`--help`::
`-?`::
  Displays the help text for the subcommand.
`--target`::
  This option specifies the target for which you are creating the
  JavaMail session resource. Valid values are:
+
  `server`;;
    Creates the resource for the default server instance. This is the
    default value.
  `domain`;;
    Creates the resource for the domain.
  cluster_name;;
    Creates the resource for every server instance in the cluster.
  instance_name;;
    Creates the resource for a particular server instance.
`--mailhost`::
  The DNS name of the default mail server. The connect methods of the
  Store and Transport objects use this value if a protocol-specific host
  property is not supplied. The name must be resolvable to an actual
  host name.
`--mailuser`::
  The name of the mail account user provided when connecting to a mail
  server. The connect methods of the Store and Transport objects use
  this value if a protocol-specific username property is not supplied.
`--fromaddress`::
  The email address of the default user, in the form
  username`@`host`.`domain.
`--storeprotocol`::
  The mail server store protocol. The default is `imap`. Change this
  value only if you have reconfigured the {productName}'s mail
  provider to use a non-default store protocol.
`--storeprotocolclass`::
  The mail server store protocol class name. The default is
  `com.sun.mail.imap.IMAPStore`. Change this value only if you have
  reconfigured the {productName}'s mail provider to use a nondefault
  store protocol.
`--transprotocol`::
  The mail server transport protocol. The default is `smtp`. Change this
  value only if you have reconfigured the {productName}'s mail
  provider to use a nondefault transport protocol.
`--transprotocolclass`::
  The mail server transport protocol class name. The default is
  `com.sun.mail.smtp.SMTPTransport`. Change this value only if you have
  reconfigured the {productName}'s mail provider to use a nondefault
  transport protocol.
`--debug`::
  If set to true, the server starts up in debug mode for this resource.
  If the JavaMail log level is set to `FINE` or `FINER`, the debugging
  output will be generated and will be included in the server log file.
  The default value is false.
`--enabled`::
  If set to true, the resource is enabled at runtime. The default value
  is true.
`--description`::
  Text providing some details of the JavaMail resource.
`--property`::
  Optional attribute name/value pairs for configuring the JavaMail
  resource. The {productName}-specific ``mail-`` prefix is converted
  to the standard mail prefix. The JavaMail API documentation lists the
  properties you might want to set.

[[sthref315]]

=== Operands

jndi-name::
  The JNDI name of the JavaMail resource to be created. It is a
  recommended practice to use the naming subcontext prefix `mail/` for
  JavaMail resources.

[[sthref316]]

=== Examples

[[GSRFM492]][[sthref317]]

==== Example 1   Creating a JavaMail Resource

This example creates a JavaMail resource named `mail/MyMailSession`. The
JNDI name for a JavaMail session resource customarily includes the
`mail/` naming subcontext.

[source]
----
asadmin> create-javamail-resource --mailhost localhost
--mailuser sample --fromaddress sample@sun.com mail/MyMailSession
Command create-javamail-resource executed successfully.
----

[[sthref318]]

=== Exit Status

0::
  subcommand executed successfully
1::
  error in executing the subcommand

[[sthref319]]

=== See Also

link:asadmin.html#asadmin-1m[`asadmin`(1M)]

link:delete-javamail-resource.html#delete-javamail-resource-1[`delete-javamail-resource`(1)],
link:list-javamail-resources.html#list-javamail-resources-1[`list-javamail-resources`(1)]


