<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- NewPage --> <html lang="en"> <head> <!-- Generated by javadoc --> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Overview (JavaMail API documentation)</title> <link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style"> <script type="text/javascript" src="script.js"></script> </head> <body> <script type="text/javascript"><!-- try { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Overview (JavaMail API documentation)"; } } catch(err) { } //--> </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <!-- ========= START OF TOP NAVBAR ======= --> <div class="topNav"><a name="navbar.top"> <!-- --> </a> <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> <a name="navbar.top.firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li class="navBarCell1Rev">Overview</li> <li>Package</li> <li>Class</li> <li>Use</li> <li><a href="overview-tree.html">Tree</a></li> <li><a href="deprecated-list.html">Deprecated</a></li> <li><a href="index-files/index-1.html">Index</a></li> <li><a href="help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li>Prev</li> <li>Next</li> </ul> <ul class="navList"> <li><a href="index.html?overview-summary.html" target="_top">Frames</a></li> <li><a href="overview-summary.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_top"> <li><a href="allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_top"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip.navbar.top"> <!-- --> </a></div> <!-- ========= END OF TOP NAVBAR ========= --> <div class="header"> <h1 class="title">JavaMail API documentation</h1> </div> <div class="header"> <div class="subTitle"> <div class="block">The JavaMail<sup><font size="-2">TM</font></sup> API provides classes that model a mail system.</div> </div> <p>See: <a href="#overview.description">Description</a></p> </div> <div class="contentContainer"> <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="JavaMail API Packages table, listing packages, and an explanation"> <caption><span>JavaMail API Packages</span><span class="tabEnd"> </span></caption> <tr> <th class="colFirst" scope="col">Package</th> <th class="colLast" scope="col">Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><a href="javax/mail/package-summary.html">javax.mail</a></td> <td class="colLast"> <div class="block">The JavaMail<sup><font size="-2">TM</font></sup> API provides classes that model a mail system.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><a href="javax/mail/event/package-summary.html">javax.mail.event</a></td> <td class="colLast"> <div class="block">Listeners and events for the JavaMail API.</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><a href="javax/mail/internet/package-summary.html">javax.mail.internet</a></td> <td class="colLast"> <div class="block">Classes specific to Internet mail systems.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><a href="javax/mail/search/package-summary.html">javax.mail.search</a></td> <td class="colLast"> <div class="block">Message search terms for the JavaMail API.</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><a href="javax/mail/util/package-summary.html">javax.mail.util</a></td> <td class="colLast"> <div class="block">JavaMail API utility classes.</div> </td> </tr> </tbody> </table> </div> <div class="contentContainer"> <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="RI-specific Packages table, listing packages, and an explanation"> <caption><span>RI-specific Packages</span><span class="tabEnd"> </span></caption> <tr> <th class="colFirst" scope="col">Package</th> <th class="colLast" scope="col">Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><a href="com/sun/mail/dsn/package-summary.html">com.sun.mail.dsn</a></td> <td class="colLast"> <div class="block">Support for creating and parsing Delivery Status Notifications.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><a href="com/sun/mail/gimap/package-summary.html">com.sun.mail.gimap</a></td> <td class="colLast"> <div class="block">An EXPERIMENTAL IMAP protocol provider that supports the <A HREF="https://developers.google.com/google-apps/gmail/imap_extensions" TARGET="_top"> Gmail-specific IMAP protocol extensions </A>.</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><a href="com/sun/mail/imap/package-summary.html">com.sun.mail.imap</a></td> <td class="colLast"> <div class="block">An IMAP protocol provider for the JavaMail API that provides access to an IMAP message store.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><a href="com/sun/mail/pop3/package-summary.html">com.sun.mail.pop3</a></td> <td class="colLast"> <div class="block">A POP3 protocol provider for the JavaMail API that provides access to a POP3 message store.</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><a href="com/sun/mail/smtp/package-summary.html">com.sun.mail.smtp</a></td> <td class="colLast"> <div class="block">An SMTP protocol provider for the JavaMail API that provides access to an SMTP server.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><a href="com/sun/mail/util/package-summary.html">com.sun.mail.util</a></td> <td class="colLast"> <div class="block">Utility classes for use with the JavaMail API.</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><a href="com/sun/mail/util/logging/package-summary.html">com.sun.mail.util.logging</a></td> <td class="colLast"> <div class="block">Contains JavaMail<sup><font size="-2">TM</font></sup> extensions for the Java<SUP><FONT SIZE="-2">TM</FONT></SUP> platform's core logging facilities.</div> </td> </tr> </tbody> </table> </div> <div class="contentContainer"><a name="overview.description"> <!-- --> </a> <div class="block">The JavaMail<sup><font size="-2">TM</font></sup> API provides classes that model a mail system. The <code>javax.mail</code> package defines classes that are common to all mail systems. The <code>javax.mail.internet</code> package defines classes that are specific to 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. <P> For an overview of the JavaMail API, read the <A HREF="http://javamail.java.net/nonav/docs/JavaMail-1.5.pdf" TARGET="_top"> JavaMail specification</A>. <P> The code to send a plain text message can be as simple as the following: <PRE> Properties props = new Properties(); props.put("mail.smtp.host", "my-mail-server"); Session session = Session.getInstance(props, null); try { MimeMessage msg = new MimeMessage(session); msg.setFrom("me@example.com"); msg.setRecipients(Message.RecipientType.TO, "you@example.com"); msg.setSubject("JavaMail hello world example"); msg.setSentDate(new Date()); msg.setText("Hello, world!\n"); Transport.send(msg, "me@example.com", "my-password"); } catch (MessagingException mex) { System.out.println("send failed, exception: " + mex); } </PRE> The JavaMail download bundle contains many more complete examples in the "demo" directory. <P> Don't forget to see the <A HREF="http://www.oracle.com/technetwork/java/javamail/faq/" TARGET="_top"> JavaMail API FAQ</A> for answers to the most common questions. The <A HREF="http://www.oracle.com/technetwork/java/javamail/" TARGET="_top"> JavaMail web site</A> contains many additional resources. <P> <A NAME="properties"> <H4>Properties</H4> </A> 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 <PRE> props.put("mail.debug", "true"); </PRE> to set the <code>mail.debug</code> property, which is of type boolean. <P> <TABLE BORDER> <TR> <TH>Name</TH> <TH>Type</TH> <TH>Description</TH> </TR> <A NAME="mail.debug"></A> <TR id="mail.debug"> <TD>mail.debug</TD> <TD>boolean</TD> <TD> The initial debug mode. Default is false. </TD> </TR> <A NAME="mail.from"></A> <TR id="mail.from"> <TD>mail.from</TD> <TD>String</TD> <TD> The return email address of the current user, used by the <code>InternetAddress</code> method <code>getLocalAddress</code>. </TD> </TR> <A NAME="mail.mime.address.strict"></A> <TR id="mail.mime.address.strict"> <TD>mail.mime.address.strict</TD> <TD>boolean</TD> <TD> 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. </TD> </TR> <A NAME="mail.host"></A> <TR id="mail.host"> <TD>mail.host</TD> <TD>String</TD> <TD> 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. </TD> </TR> <A NAME="mail.store.protocol"></A> <TR id="mail.store.protocol"> <TD>mail.store.protocol</TD> <TD>String</TD> <TD> 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. </TD> </TR> <A NAME="mail.transport.protocol"></A> <TR id="mail.transport.protocol"> <TD>mail.transport.protocol</TD> <TD>String</TD> <TD> 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. </TD> </TR> <A NAME="mail.user"></A> <TR id="mail.user"> <TD>mail.user</TD> <TD>String</TD> <TD> 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> </TR> <A NAME="mail.protocol.class"></A> <TR id="mail.protocol.class"> <TD>mail.<i>protocol</i>.class</TD> <TD>String</TD> <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 in a configuration file. </TD> </TR> <A NAME="mail.protocol.host"></A> <TR id="mail.protocol.host"> <TD>mail.<i>protocol</i>.host</TD> <TD>String</TD> <TD> The host name of the mail server for the specified protocol. Overrides the <code>mail.host</code> property. </TD> </TR> <A NAME="mail.protocol.port"></A> <TR id="mail.protocol.port"> <TD>mail.<i>protocol</i>.port</TD> <TD>int</TD> <TD> The port number of the mail server for the specified protocol. If not specified the protocol's default port number is used. </TD> </TR> <A NAME="mail.protocol.user"></A> <TR id="mail.protocol.user"> <TD>mail.<i>protocol</i>.user</TD> <TD>String</TD> <TD> The user name to use when connecting to mail servers using the specified protocol. Overrides the <code>mail.user</code> property. </TD> </TR> </TABLE> <P> 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. <P> <TABLE BORDER> <TR> <TH>Name</TH> <TH>Type</TH> <TH>Description</TH> </TR> <A NAME="mail.debug.auth"></A> <TR id="mail.debug.auth"> <TD>mail.debug.auth</TD> <TD>boolean</TD> <TD> Include protocol authentication commands (including usernames and passwords) in the debug output. Default is false. </TD> </TR> <A NAME="mail.transport.protocol.address-type"></A> <TR id="mail.transport.protocol.address-type"> <TD>mail.transport.protocol.<i>address-type</i></TD> <TD>String</TD> <TD> 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 <a href="javax/mail/Transport.html#send-javax.mail.Message-"><code>send</code></a> method of the <a href="javax/mail/Transport.html" title="class in javax.mail"><code>Transport</code></a> class so that (for example) the "smtps" protocol is used instead of the "smtp" protocol by setting the property <code>mail.transport.protocol.rfc822</code> to <code>"smtps"</code>. </TD> </TR> <A NAME="mail.event.scope"></A> <TR id="mail.event.scope"> <TD>mail.event.scope</TD> <TD>String</TD> <TD> Controls the scope of events. (See the javax.mail.event package.) By default, a separate event queue and thread is used for events for each Store, Transport, or Folder. If this property is set to "session", all such events are put in a single event queue processed by a single thread for the current session. If this property is set to "application", all such events are put in a single event queue processed by a single thread for the current application. (Applications are distinguished by their context class loader.) </TD> </TR> <A NAME="mail.event.executor"></A> <TR id="mail.event.executor"> <TD>mail.event.executor</TD> <TD>java.util.concurrent.Executor</TD> <TD> By default, a new Thread is created for each event queue. This thread is used to call the listeners for these events. If this property is set to an instance of an Executor, the Executor.execute method is used to run the event dispatcher for an event queue. The event dispatcher runs until the event queue is no longer in use. </TD> </TR> </TABLE> <P> The JavaMail API also supports several System properties; see the <a href="javax/mail/internet/package-summary.html"><code>javax.mail.internet</code></a> package documentation for details. <P> The JavaMail reference 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. <P> Nonportable programs may use the APIs of the protocol providers by (for example) casting a returned <code>Folder</code> object to a <code>com.sun.mail.imap.IMAPFolder</code> object. Similarly for <code>Store</code> and <code>Message</code> objects returned from the standard JavaMail APIs. <P> The protocol providers also support properties that are specific to those providers. The package documentation for the <a href="com/sun/mail/imap/package-summary.html"><code>IMAP</code></a>, <a href="com/sun/mail/pop3/package-summary.html"><code>POP3</code></a>, and <a href="com/sun/mail/smtp/package-summary.html"><code>SMTP</code></a> packages provide details. <P> In addition to printing debugging output as controlled by the <a href="javax/mail/Session.html" title="class in javax.mail"><code>Session</code></a> configuration, the current implementation of classes in this package log the same information using <a href="http://docs.oracle.com/javase/1.5.0/docs/api/./java/util/logging/Logger.html?is-external=true" title="class or interface in java.util.logging"><code>Logger</code></a> as described in the following table: <P> <TABLE BORDER> <TR> <TH>Logger Name</TH> <TH>Logging Level</TH> <TH>Purpose</TH> </TR> <TR> <TD>javax.mail</TD> <TD>CONFIG</TD> <TD>Configuration of the Session</TD> </TR> <TR> <TD>javax.mail</TD> <TD>FINE</TD> <TD>General debugging output</TD> </TR> </TABLE></div> </div> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a name="navbar.bottom"> <!-- --> </a> <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> <a name="navbar.bottom.firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li class="navBarCell1Rev">Overview</li> <li>Package</li> <li>Class</li> <li>Use</li> <li><a href="overview-tree.html">Tree</a></li> <li><a href="deprecated-list.html">Deprecated</a></li> <li><a href="index-files/index-1.html">Index</a></li> <li><a href="help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li>Prev</li> <li>Next</li> </ul> <ul class="navList"> <li><a href="index.html?overview-summary.html" target="_top">Frames</a></li> <li><a href="overview-summary.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_bottom"> <li><a href="allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_bottom"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip.navbar.bottom"> <!-- --> </a></div> <!-- ======== END OF BOTTOM NAVBAR ======= --> <p class="legalCopy"><small>Copyright © 1996-2017, <a href="http://www.oracle.com">Oracle</a> and/or its affiliates. All Rights Reserved. Use is subject to <a href="./doc-files/speclicense.html" target="_top">license terms</a>.</small></p> </body> </html>