0N/A<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
292N/A DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 720N/A Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved. 292N/A The contents of this file are subject to the terms of either the GNU 292N/A General Public License Version 2 only ("GPL") or the Common Development 292N/A and Distribution License("CDDL") (collectively, the "License"). You 292N/A may not use this file except in compliance with the License. You can 292N/A obtain a copy of the License at 292N/A language governing permissions and limitations under the License. 292N/A When distributing the software, include this License Header Notice in each 292N/A GPL Classpath Exception: 292N/A Oracle designates this particular file as subject to the "Classpath" 292N/A exception as provided by Oracle in the GPL Version 2 section of the License 292N/A file that accompanied this code. 292N/A If applicable, add the following below the License Header, with the fields 292N/A enclosed by brackets [] replaced by your own identifying information: 292N/A "Portions Copyright [year] [name of copyright owner]" 292N/A If you wish your version of this file to be governed by only the CDDL or 292N/A only the GPL Version 2, indicate your decision by adding "[Contributor] 292N/A elects to include this software in this distribution under the [CDDL or GPL 292N/A Version 2] license." If you don't indicate a single choice of license, a 292N/A recipient has the option to distribute your version of this file under 292N/A either the CDDL, the GPL Version 2 or to extend the choice of license to 292N/A its licensees as provided above. However, if you add GPL Version 2 code 292N/A and therefore, elected the GPL Version 2 license, then the option applies 292N/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.
720N/AFor an overview of the JavaMail API, read the
720N/AJavaMail specification</
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 initial debug mode.
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.
137N/ASpecifies the default message transport protocol. The
0N/A<
code>Session</
code> method <
code>getTransport()</
code> returns a Transport
0N/Aobject that implements this protocol. By default the first Transport
0N/Aprovider in the configuration files is returned.
0N/AThe default user name to use when connecting to the mail server.
0N/AUsed if the <
code>mail.<
i>protocol</
i>.user</
code> property isn't set.
0N/A<
TD>mail.<
i>protocol</
i>.class</
TD>
0N/ASpecifies the fully qualified class name of the provider for the
0N/Aspecified protocol. Used in cases where more than one provider
0N/Afor a given protocol exists; this property can be used to specify
0N/Awhich provider to use by default. The provider must still be listed
0N/Ain a configuration file.
0N/A<
TD>mail.<
i>protocol</
i>.host</
TD>
0N/AThe host name of the mail server for the specified protocol.
0N/A<
TD>mail.<
i>protocol</
i>.port</
TD>
0N/AThe port number of the mail server for the specified protocol.
0N/AIf not specified the protocol's default port number is used.
0N/A<
TD>mail.<
i>protocol</
i>.user</
TD>
0N/AThe user name to use when connecting to mail servers
0N/Ausing the specified protocol.
575N/AThe following properties are supported by the reference implementation (RI) of
137N/AJavaMail, but are not currently a required part of the specification.
137N/AThe names, types, defaults, and semantics of these properties may
137N/Achange in future releases.
433N/AInclude protocol authentication commands (including usernames and passwords)
137N/ASpecifies the default message transport protocol for the specified address type.
137N/AThe <
code>Session</
code> method <
code>getTransport(Address)</
code> returns a
137N/ATransport object that implements this protocol when the address is of the
137N/Aspecified type (
e.g., "rfc822" for standard internet addresses).
137N/ABy default the first Transport configured for that address type is used.
137N/AThis property can be used to override the behavior of the
137N/Aprotocol is used instead of the "smtp" protocol by setting the property
720N/ABy default, a separate event queue and thread is used for events for each
720N/AStore, Transport, or Folder.
720N/AIf this property is set to "session", all such events are put in a single
720N/Aevent queue processed by a single thread for the current session.
720N/AIf this property is set to "application", all such events are put in a single
720N/Aevent queue processed by a single thread for the current application.
720N/A(Applications are distinguished by their context class loader.)
720N/ABy default, a new Thread is created for each event queue.
720N/AThis thread is used to call the listeners for these events.
720N/AIf this property is set to an instance of an Executor, the
720N/Afor an event queue. The event dispatcher runs until the
720N/Aevent queue is no longer in use.
0N/AThe JavaMail API also supports several System properties;
0N/AThe JavaMail reference
575N/Aimplementation includes protocol providers in subpackages of
0N/Aproviders are not part of the standard JavaMail API. Portable
0N/Aprograms will not use these APIs.
575N/ANonportable programs may use the APIs of the protocol providers
0N/Aby (for example) casting a returned <
code>Folder</
code> object to a
0N/A<
code>Store</
code> and <
code>Message</
code> objects returned from the
0N/Astandard JavaMail APIs.
575N/AThe protocol providers also support properties that are specific to
0N/Athose providers. The package documentation for the
720N/AIn addition to printing debugging output as controlled by the
720N/Aimplementation of classes in this package log the same information using
720N/A<
TD>Configuration of the Session</
TD>
720N/A<
TD>General debugging output</
TD>