0N/A<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
0N/A DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 0N/A Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved. 0N/A The contents of this file are subject to the terms of either the GNU 0N/A General Public License Version 2 only ("GPL") or the Common Development 0N/A and Distribution License("CDDL") (collectively, the "License"). You 0N/A may not use this file except in compliance with the License. You can 0N/A obtain a copy of the License at 0N/A language governing permissions and limitations under the License. 0N/A When distributing the software, include this License Header Notice in each 157N/A GPL Classpath Exception: 157N/A Oracle designates this particular file as subject to the "Classpath" 0N/A exception as provided by Oracle in the GPL Version 2 section of the License 0N/A file that accompanied this code. 0N/A If applicable, add the following below the License Header, with the fields 0N/A enclosed by brackets [] replaced by your own identifying information: 0N/A "Portions Copyright [year] [name of copyright owner]" 0N/A If you wish your version of this file to be governed by only the CDDL or 0N/A only the GPL Version 2, indicate your decision by adding "[Contributor] 0N/A elects to include this software in this distribution under the [CDDL or GPL 0N/A Version 2] license." If you don't indicate a single choice of license, a 0N/A recipient has the option to distribute your version of this file under 0N/A either the CDDL, the GPL Version 2 or to extend the choice of license to 0N/A its licensees as provided above. However, if you add GPL Version 2 code 0N/A and therefore, elected the GPL Version 2 license, then the option applies 0N/A only if the new code is made subject to such option by the copyright 0N/A<
BODY BGCOLOR="white">
0N/AThe JavaMail<
sup><
font size="-2">TM</
font></
sup> API
0N/Aprovides classes that model a mail system.
0N/AThe <
code>
javax.mail</
code> package defines classes that are common to
0N/Ato mail systems based on internet standards such as MIME, SMTP, POP3, and IMAP.
The JavaMail API includes the <
code>
javax.mail</
code> package and subpackages.
For an overview of the JavaMail API, read the JavaMail specification
included in the download bundle</
A> or
available on the JavaMail web site</
A>.
The code to send a plain text message can be as simple as the following:
Properties props = new Properties();
MimeMessage msg = new MimeMessage(session);
} catch (MessagingException mex) {
The JavaMail download bundle contains many more complete examples
for answers to the most common questions.
contains many additional resources.
The JavaMail API supports the following standard properties,
which may be set in the <
code>Session</
code> object, or in the
<
code>Properties</
code> object used to create the <
code>Session</
code> object.
The properties are always set as strings; the Type column describes
how the string is interpreted. For example, use
to set the <
code>
mail.debug</
code> property, which is of type boolean.
The return email address of the current user, used by the
<
code>InternetAddress</
code> method <
code>getLocalAddress</
code>.
The MimeMessage class uses the <
code>InternetAddress</
code> method
<
code>parseHeader</
code> to parse headers in messages. This property
controls the strict flag passed to the <
code>parseHeader</
code>
method. The default is true.
The default host name of the mail server for both Stores and Transports.
Used if the <
code>mail.<
i>protocol</
i>.host</
code> property isn't set.
Specifies the default message access protocol. The
<
code>Session</
code> method <
code>getStore()</
code> returns a Store
object that implements this protocol. By default the first Store
provider in the configuration files is returned.
Specifies the default message transport protocol. The
<
code>Session</
code> method <
code>getTransport()</
code> returns a Transport
object that implements this protocol. By default the first Transport
provider in the configuration files is returned.
The default user name to use when connecting to the mail server.
Used if the <
code>mail.<
i>protocol</
i>.user</
code> property isn't set.
<
TD>mail.<
i>protocol</
i>.class</
TD>
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
<
TD>mail.<
i>protocol</
i>.host</
TD>
The host name of the mail server for the specified protocol.
Overrides the <
code>
mail.host</
code> property.
<
TD>mail.<
i>protocol</
i>.port</
TD>
The port number of the mail server for the specified protocol.
If not specified the protocol's default port number is used.
<
TD>mail.<
i>protocol</
i>.user</
TD>
The user name to use when connecting to mail servers
using the specified protocol.
Overrides the <
code>
mail.user</
code> property.
The following properties are supported by the reference implementation (RI) of
JavaMail, but are not currently a required part of the specification.
The names, types, defaults, and semantics of these properties may
change in future releases.
Include protocol authentication commands (including usernames and passwords)
Specifies the default message transport protocol for the specified address type.
The <
code>Session</
code> method <
code>getTransport(Address)</
code> returns a
Transport object that implements this protocol when the address is of the
specified type (
e.g., "rfc822" for standard internet addresses).
By default the first Transport configured for that address type is used.
This property can be used to override the behavior of the
protocol is used instead of the "smtp" protocol by setting the property
The JavaMail API also supports several System properties;
implementation includes protocol providers in subpackages of
<
code>
com.sun.mail</
code>. Note that the APIs to these protocol
providers are not part of the standard JavaMail API. Portable
programs will not use these APIs.
Nonportable programs may use the APIs of the protocol providers
by (for example) casting a returned <
code>Folder</
code> object to a
<
code>Store</
code> and <
code>Message</
code> objects returned from the
The protocol providers also support properties that are specific to
those providers. The package documentation for the