1178N/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-2010 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 1178N/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.
0N/AThe JavaMail API includes the <
code>
javax.mail</
code> package and subpackages.
1178N/AFor an overview of the JavaMail API, read the JavaMail specification
0N/Aincluded in the download bundle</
A> or
0N/Aavailable on the JavaMail web site</
A>.
0N/AThe code to send a plain text message can be as simple as the following:
0N/A Properties props = new Properties();
0N/A MimeMessage msg = new MimeMessage(session);
0N/A } catch (MessagingException mex) {
0N/AThe JavaMail download bundle contains many more complete examples
0N/Ain the "demo" directory.
0N/ADon't forget to see the
0N/Afor answers to the most common questions.
0N/AJavaMail web site</
A>
0N/Acontains many additional resources.
0N/AThe JavaMail API supports the following standard properties,
0N/Awhich may be set in the <
code>Session</
code> object, or in the
0N/A<
code>Properties</
code> object used to create the <
code>Session</
code> object.
0N/AThe properties are always set as strings; the Type column describes
0N/Ahow the string is interpreted. For example, use
0N/Ato set the <
code>
mail.debug</
code> property, which is of type boolean.
0N/AThe return email address of the current user, used by the
0N/A<
code>InternetAddress</
code> method <
code>getLocalAddress</
code>.
0N/AThe MimeMessage class uses the <
code>InternetAddress</
code> method
0N/A<
code>parseHeader</
code> to parse headers in messages. This property
0N/Acontrols the strict flag passed to the <
code>parseHeader</
code>
0N/Amethod. The default is true.
0N/AThe default host name of the mail server for both Stores and Transports.
0N/AUsed if the <
code>mail.<
i>protocol</
i>.host</
code> property isn't set.
0N/ASpecifies the default message access protocol. The
0N/A<
code>Session</
code> method <
code>getStore()</
code> returns a Store
0N/Aobject that implements this protocol. By default the first Store
0N/Aprovider in the configuration files is returned.
0N/ASpecifies the default message transport protocol. The
0N/A<
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 Sun's implementation 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.
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 from Sun 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 Sun 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 Sun protocol providers also support properties that are specific to
those providers. The package documentation for the