blob: dad1d8c5a09e8b51815fe9a47b598f53f18481bf [file] [log] [blame]
<!--
Copyright (c) 2005, 2018 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-->
<p><a id="task-javamailsessioncreate" name="task-javamailsessioncreate"></a><a id="GHJML00011" name="GHJML00011"></a></p>
<h4><a id="sthref4" name="sthref4"></a>To Create a JavaMail Session</h4>
<a name="BEGIN" id="BEGIN"></a>
<ol>
<li>
<p>In the navigation tree, expand the Resources node.</p>
</li>
<li>
<p>Under the Resources node, select JavaMail Sessions.</p>
<p>The JavaMail Sessions page opens.</p>
</li>
<li>
<p>In the Sessions table, click New.</p>
<p>The New JavaMail Session page opens.</p>
</li>
<li>
<p>In the JNDI Name field, type a unique name for the mail session resource.</p>
<p>Use the naming sub-context prefix <code>mail/</code> for JavaMail resources. For example: <code>mail/MySession</code>. The name must contain only alphanumeric, underscore, dash, or dot characters.</p>
</li>
<li>
<p>In the Mail Host field, type the host name of the default mail server.</p>
<p>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.</p>
</li>
<li>
<p>In the Default User field, type the user name to provide when connecting to a mail server.</p>
<p>The connect methods of the Store and Transport objects use this value if a protocol-specific username property is not supplied. The user name must contain only alphanumeric, underscore, dash, or dot characters.</p>
</li>
<li>
<p>In the Default Sender Address field, type the e-mail address of the default user.</p>
<p>The format is <i>username</i><code>@</code><i>host</i>.<i>domain</i>.</p>
</li>
<li>
<p>In the Description field, type a description of this mail session.</p>
</li>
<li>
<p>Select the Status Enabled checkbox to enable the mail session.</p>
<p>The default value is Enabled.</p>
</li>
<li>
<p>In the Store Protocol field, define the storage protocol service to be used.</p>
<p>The storage protocol service connects to a mail server, retrieves messages, and saves messages in one or more folders. Allowed values are <code>imap</code>, <code>pop3</code>, <code>imaps</code>, and <code>pop3s</code>. The default value is <code>imap</code>.</p>
</li>
<li>
<p>In the Store Protocol Class field, specify the service provider implementation class for storage.</p>
<p>Allowed values are:</p>
<ul>
<li>
<p><code>com.sun.mail.imap.IMAPStore</code></p>
</li>
<li>
<p><code>com.sun.mail.pop3.POP3Store</code></p>
</li>
<li>
<p><code>com.sun.mail.imap.IMAPSSLStore</code></p>
</li>
<li>
<p><code>com.sun.mail.pop3.POP3SSLStore</code></p>
</li>
</ul>
<p>The default value is <code>com.sun.mail.imap.IMAPStore</code>.</p>
</li>
<li>
<p>In the Transport Protocol field, specify the transport communication method.</p>
<p>The transport protocol service sends messages. Allowed values are <code>smtp</code> and <code>smtps</code>. By default, the Transport Protocol is <code>smtp</code>.</p>
</li>
<li>
<p>In the Transport Protocol Class field, specify the service provider implementation class for transport.</p>
<p>The default value is <code>com.sun.mail.smtp.SMTPTransport</code>.</p>
</li>
<li>
<p>Select the Debug checkbox to enable extra debugging output, including a protocol trace, for this mail session.</p>
<p>If the JavaMail log level is set to <code>FINE</code> or finer, the debugging output is generated and is included in the system log file. See <a href="../../../common/en/help/task-eelogginglevels.html">To Configure Log Levels</a> for information about setting the log level. This option is disabled by default.</p>
</li>
<li>
<p>In the Additional Properties table, specify additional properties required by applications, such as a protocol-specific host or username property.</p>
<p>For a list of the available properties, see the JavaMail API documentation (<code><a href="http://java.sun.com/products/javamail/javadocs/index.html">http://java.sun.com/products/javamail/javadocs/index.html</a></code>). Additional properties must begin with <code>mail-</code> and must use hyphens, not periods, as separators. For example, <code>mail-debug</code> is correct, but <code>mail.debug</code> is not. The GlassFish Server back end converts the hyphens into the periods expected by the JavaMail API.</p>
<p>To add a property, click the Add Property button. In the blank row that appears, type the property name in the Name field, and type the property value in the Value field.</p>
</li>
<li>
<p>From the list of available targets, select the target or targets to which to configure the mail session and click Add.</p>
<p>Targets can be clusters or standalone server instances. If you do not select a target, the session is configured to the default server instance <code>server</code>.</p>
</li>
<li>
<p>Click OK.</p>
</li>
</ol>
<a id="GHJML103" name="GHJML103"></a>
<h5>See Also</h5>
<ul>
<li>
<p><a href="task-javamailsessionsedit.html">To Edit a JavaMail Session</a></p>
</li>
<li>
<p><a href="task-javamailsessionsdelete.html">To Delete a JavaMail Session</a></p>
</li>
</ul>
<small>Copyright &#169; 2005, 2017, Oracle and/or its affiliates. All rights reserved. <a href="docinfo.html">Legal Notices</a></small>