Subversion Repositories javautils

Rev

Blame | Last modification | View Log | RSS feed

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <!--NewPage-->
  3. <HTML>
  4. <HEAD>
  5. <!-- Generated by javadoc (build 1.6.0_10) on Tue Nov 17 12:13:45 PST 2009 -->
  6. <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  7. <TITLE>
  8. Overview (JavaMail API documentation)
  9. </TITLE>
  10.  
  11. <META NAME="date" CONTENT="2009-11-17">
  12.  
  13. <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
  14.  
  15. <SCRIPT type="text/javascript">
  16. function windowTitle()
  17. {
  18.     if (location.href.indexOf('is-external=true') == -1) {
  19.         parent.document.title="Overview (JavaMail API documentation)";
  20.     }
  21. }
  22. </SCRIPT>
  23. <NOSCRIPT>
  24. </NOSCRIPT>
  25.  
  26. </HEAD>
  27.  
  28. <BODY BGCOLOR="white" onload="windowTitle();">
  29. <HR>
  30.  
  31.  
  32. <!-- ========= START OF TOP NAVBAR ======= -->
  33. <A NAME="navbar_top"><!-- --></A>
  34. <A HREF="#skip-navbar_top" title="Skip navigation links"></A>
  35. <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
  36. <TR>
  37. <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
  38. <A NAME="navbar_top_firstrow"><!-- --></A>
  39. <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  40.   <TR ALIGN="center" VALIGN="top">
  41.   <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Overview</B></FONT>&nbsp;</TD>
  42.   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <FONT CLASS="NavBarFont1">Package</FONT>&nbsp;</TD>
  43.   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <FONT CLASS="NavBarFont1">Class</FONT>&nbsp;</TD>
  44.   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <FONT CLASS="NavBarFont1">Use</FONT>&nbsp;</TD>
  45.   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="overview-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  46.   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  47.   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  48.   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  49.   </TR>
  50. </TABLE>
  51. </TD>
  52. <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
  53. </EM>
  54. </TD>
  55. </TR>
  56.  
  57. <TR>
  58. <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  59. &nbsp;PREV&nbsp;
  60. &nbsp;NEXT</FONT></TD>
  61. <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  62.   <A HREF="index.html?overview-summary.html" target="_top"><B>FRAMES</B></A>  &nbsp;
  63. &nbsp;<A HREF="overview-summary.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
  64. &nbsp;<SCRIPT type="text/javascript">
  65.   <!--
  66.   if(window==top) {
  67.     document.writeln('<A HREF="allclasses-noframe.html"><B>All Classes</B></A>');
  68.   }
  69.   //-->
  70. </SCRIPT>
  71. <NOSCRIPT>
  72.   <A HREF="allclasses-noframe.html"><B>All Classes</B></A>
  73. </NOSCRIPT>
  74.  
  75.  
  76. </FONT></TD>
  77. </TR>
  78. </TABLE>
  79. <A NAME="skip-navbar_top"></A>
  80. <!-- ========= END OF TOP NAVBAR ========= -->
  81.  
  82. <HR>
  83. <CENTER>
  84. <H1>
  85. JavaMail API documentation
  86. </H1>
  87. </CENTER>
  88. The JavaMail<sup><font size="-2">TM</font></sup> API
  89. provides classes that model a mail system.
  90. <P>
  91. <B>See:</B>
  92. <BR>
  93. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="#overview_description"><B>Description</B></A>
  94. <P>
  95.  
  96. <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
  97. <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
  98. <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
  99. <B>JavaMail API Packages</B></FONT></TH>
  100. </TR>
  101. <TR BGCOLOR="white" CLASS="TableRowColor">
  102. <TD WIDTH="20%"><B><A HREF="javax/mail/package-summary.html">javax.mail</A></B></TD>
  103. <TD>The JavaMail<sup><font size="-2">TM</font></sup> API
  104. provides classes that model a mail system.</TD>
  105. </TR>
  106. <TR BGCOLOR="white" CLASS="TableRowColor">
  107. <TD WIDTH="20%"><B><A HREF="javax/mail/event/package-summary.html">javax.mail.event</A></B></TD>
  108. <TD>Listeners and events for the JavaMail API.</TD>
  109. </TR>
  110. <TR BGCOLOR="white" CLASS="TableRowColor">
  111. <TD WIDTH="20%"><B><A HREF="javax/mail/internet/package-summary.html">javax.mail.internet</A></B></TD>
  112. <TD>Classes specific to Internet mail systems.</TD>
  113. </TR>
  114. <TR BGCOLOR="white" CLASS="TableRowColor">
  115. <TD WIDTH="20%"><B><A HREF="javax/mail/search/package-summary.html">javax.mail.search</A></B></TD>
  116. <TD>Message search terms for the JavaMail API.</TD>
  117. </TR>
  118. <TR BGCOLOR="white" CLASS="TableRowColor">
  119. <TD WIDTH="20%"><B><A HREF="javax/mail/util/package-summary.html">javax.mail.util</A></B></TD>
  120. <TD>JavaMail API utility classes.</TD>
  121. </TR>
  122. </TABLE>
  123.  
  124. <P>
  125. &nbsp;
  126. <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
  127. <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
  128. <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
  129. <B>Sun-specific Packages</B></FONT></TH>
  130. </TR>
  131. <TR BGCOLOR="white" CLASS="TableRowColor">
  132. <TD WIDTH="20%"><B><A HREF="com/sun/mail/dsn/package-summary.html">com.sun.mail.dsn</A></B></TD>
  133. <TD>&nbsp;</TD>
  134. </TR>
  135. <TR BGCOLOR="white" CLASS="TableRowColor">
  136. <TD WIDTH="20%"><B><A HREF="com/sun/mail/imap/package-summary.html">com.sun.mail.imap</A></B></TD>
  137. <TD>An IMAP protocol provider for the JavaMail API
  138. that provides access to an IMAP message store.</TD>
  139. </TR>
  140. <TR BGCOLOR="white" CLASS="TableRowColor">
  141. <TD WIDTH="20%"><B><A HREF="com/sun/mail/pop3/package-summary.html">com.sun.mail.pop3</A></B></TD>
  142. <TD>A POP3 protocol provider for the JavaMail API
  143. that provides access to a POP3 message store.</TD>
  144. </TR>
  145. <TR BGCOLOR="white" CLASS="TableRowColor">
  146. <TD WIDTH="20%"><B><A HREF="com/sun/mail/smtp/package-summary.html">com.sun.mail.smtp</A></B></TD>
  147. <TD>An SMTP protocol provider for the JavaMail API
  148. that provides access to an SMTP server.</TD>
  149. </TR>
  150. <TR BGCOLOR="white" CLASS="TableRowColor">
  151. <TD WIDTH="20%"><B><A HREF="com/sun/mail/util/package-summary.html">com.sun.mail.util</A></B></TD>
  152. <TD>Utility classes for use with the JavaMail API.</TD>
  153. </TR>
  154. <TR BGCOLOR="white" CLASS="TableRowColor">
  155. <TD WIDTH="20%"><B><A HREF="com/sun/mail/util/logging/package-summary.html">com.sun.mail.util.logging</A></B></TD>
  156. <TD>Contains JavaMail<sup><font size="-2">TM</font></sup> extensions for
  157.       Java<SUP><FONT SIZE="-2">TM</FONT></SUP> 2 platform's core logging
  158.      facilities.</TD>
  159. </TR>
  160. </TABLE>
  161.  
  162. <P>
  163. &nbsp;<A NAME="overview_description"><!-- --></A>
  164. <P>
  165. The JavaMail<sup><font size="-2">TM</font></sup> API
  166. provides classes that model a mail system.
  167. The <code>javax.mail</code> package defines classes that are common to
  168. all mail systems.
  169. The <code>javax.mail.internet</code> package defines classes that are specific
  170. to mail systems based on internet standards such as MIME, SMTP, POP3, and IMAP.
  171. The JavaMail API includes the <code>javax.mail</code> package and subpackages.
  172. <P>
  173. For an overview of the JavaMail API, read the JavaMail specification
  174. <A HREF="../../../JavaMail-1.4.pdf" TARGET="_top">
  175. included in the download bundle</A> or
  176. <A HREF="http://java.sun.com/products/javamail/JavaMail-1.4.pdf" TARGET="_top">
  177. available on the JavaMail web site</A>.
  178. <P>
  179. The code to send a plain text message can be as simple as the following:
  180. <PRE>
  181.    Properties props = new Properties();
  182.    props.put("mail.smtp.host", "my-mail-server");
  183.    props.put("mail.from", "me@example.com");
  184.    Session session = Session.getInstance(props, null);
  185.  
  186.    try {
  187.        MimeMessage msg = new MimeMessage(session);
  188.        msg.setFrom();
  189.        msg.setRecipients(Message.RecipientType.TO,
  190.                          "you@example.com");
  191.        msg.setSubject("JavaMail hello world example");
  192.        msg.setSentDate(new Date());
  193.        msg.setText("Hello, world!\n");
  194.        Transport.send(msg);
  195.    } catch (MessagingException mex) {
  196.        System.out.println("send failed, exception: " + mex);
  197.    }
  198. </PRE>
  199. The JavaMail download bundle contains many more complete examples
  200. in the "demo" directory.
  201. <P>
  202. Don't forget to see the
  203. <A HREF="http://java.sun.com/products/javamail/FAQ.html" TARGET="_top">
  204. JavaMail API FAQ</A>
  205. for answers to the most common questions.
  206. The <A HREF="http://java.sun.com/products/javamail/" TARGET="_top">
  207. JavaMail web site</A>
  208. contains many additional resources.
  209. <P>
  210. The JavaMail API supports the following standard properties,
  211. which may be set in the <code>Session</code> object, or in the
  212. <code>Properties</code> object used to create the <code>Session</code> object.
  213. The properties are always set as strings; the Type column describes
  214. how the string is interpreted.  For example, use
  215. <PRE>
  216.         props.put("mail.debug", "true");
  217. </PRE>
  218. to set the <code>mail.debug</code> property, which is of type boolean.
  219. <P>
  220. <TABLE BORDER>
  221. <TR>
  222. <TH>Name</TH>
  223. <TH>Type</TH>
  224. <TH>Description</TH>
  225. </TR>
  226.  
  227. <TR>
  228. <TD>mail.debug</TD>
  229. <TD>boolean</TD>
  230. <TD>
  231. The initial debug mode.
  232. Default is false.
  233. </TD>
  234. </TR>
  235.  
  236. <TR>
  237. <TD>mail.from</TD>
  238. <TD>String</TD>
  239. <TD>
  240. The return email address of the current user, used by the
  241. <code>InternetAddress</code> method <code>getLocalAddress</code>.
  242. </TD>
  243. </TR>
  244.  
  245. <TR>
  246. <TD>mail.mime.address.strict</TD>
  247. <TD>boolean</TD>
  248. <TD>
  249. The MimeMessage class uses the <code>InternetAddress</code> method
  250. <code>parseHeader</code> to parse headers in messages.  This property
  251. controls the strict flag passed to the <code>parseHeader</code>
  252. method.  The default is true.
  253. </TD>
  254. </TR>
  255.  
  256. <TR>
  257. <TD>mail.host</TD>
  258. <TD>String</TD>
  259. <TD>
  260. The default host name of the mail server for both Stores and Transports.
  261. Used if the <code>mail.<i>protocol</i>.host</code> property isn't set.
  262. </TD>
  263. </TR>
  264.  
  265. <TR>
  266. <TD>mail.store.protocol</TD>
  267. <TD>String</TD>
  268. <TD>
  269. Specifies the default message access protocol.  The
  270. <code>Session</code> method <code>getStore()</code> returns a Store
  271. object that implements this protocol.  By default the first Store
  272. provider in the configuration files is returned.
  273. </TD>
  274. </TR>
  275.  
  276. <TR>
  277. <TD>mail.transport.protocol</TD>
  278. <TD>String</TD>
  279. <TD>
  280. Specifies the default message transport protocol.  The
  281. <code>Session</code> method <code>getTransport()</code> returns a Transport
  282. object that implements this protocol.  By default the first Transport
  283. provider in the configuration files is returned.
  284. </TD>
  285. </TR>
  286.  
  287. <TR>
  288. <TD>mail.user</TD>
  289. <TD>String</TD>
  290. <TD>
  291. The default user name to use when connecting to the mail server.
  292. Used if the <code>mail.<i>protocol</i>.user</code> property isn't set.
  293. </TD>
  294. </TR>
  295.  
  296. <TR>
  297. <TD>mail.<i>protocol</i>.class</TD>
  298. <TD>String</TD>
  299. <TD>
  300. Specifies the fully qualified class name of the provider for the
  301. specified protocol.  Used in cases where more than one provider
  302. for a given protocol exists; this property can be used to specify
  303. which provider to use by default.  The provider must still be listed
  304. in a configuration file.
  305. </TD>
  306. </TR>
  307.  
  308. <TR>
  309. <TD>mail.<i>protocol</i>.host</TD>
  310. <TD>String</TD>
  311. <TD>
  312. The host name of the mail server for the specified protocol.
  313. Overrides the <code>mail.host</code> property.
  314. </TD>
  315. </TR>
  316.  
  317. <TR>
  318. <TD>mail.<i>protocol</i>.port</TD>
  319. <TD>int</TD>
  320. <TD>
  321. The port number of the mail server for the specified protocol.
  322. If not specified the protocol's default port number is used.
  323. </TD>
  324. </TR>
  325.  
  326. <TR>
  327. <TD>mail.<i>protocol</i>.user</TD>
  328. <TD>String</TD>
  329. <TD>
  330. The user name to use when connecting to mail servers
  331. using the specified protocol.
  332. Overrides the <code>mail.user</code> property.
  333. </TD>
  334. </TR>
  335.  
  336. </TABLE>
  337.  
  338. <P>
  339. The following properties are supported by Sun's implementation of
  340. JavaMail, but are not currently a required part of the specification.
  341. The names, types, defaults, and semantics of these properties may
  342. change in future releases.
  343. <P>
  344. <TABLE BORDER>
  345. <TR>
  346. <TH>Name</TH>
  347. <TH>Type</TH>
  348. <TH>Description</TH>
  349. </TR>
  350.  
  351. <TR>
  352. <TD>mail.transport.protocol.<i>address-type</i></TD>
  353. <TD>String</TD>
  354. <TD>
  355. Specifies the default message transport protocol for the specified address type.
  356. The <code>Session</code> method <code>getTransport(Address)</code> returns a
  357. Transport object that implements this protocol when the address is of the
  358. specified type (e.g., "rfc822" for standard internet addresses).
  359. By default the first Transport configured for that address type is used.
  360. This property can be used to override the behavior of the
  361. <A HREF="javax/mail/Transport.html#send(javax.mail.Message)"><CODE>send</CODE></A> method of the
  362. <A HREF="javax/mail/Transport.html" title="class in javax.mail"><CODE>Transport</CODE></A> class so that (for example) the "smtps"
  363. protocol is used instead of the "smtp" protocol by setting the property
  364. <code>mail.transport.protocol.rfc822</code> to <code>"smtps"</code>.
  365. </TD>
  366. </TR>
  367.  
  368. </TABLE>
  369.  
  370. <P>
  371. The JavaMail API also supports several System properties;
  372. see the <A HREF="javax/mail/internet/package-summary.html"><CODE>javax.mail.internet</CODE></A> package documentation
  373. for details.
  374.  
  375. <P>
  376. The JavaMail reference
  377. implementation from Sun includes protocol providers in subpackages of
  378. <code>com.sun.mail</code>.  Note that the APIs to these protocol
  379. providers are not part of the standard JavaMail API.  Portable
  380. programs will not use these APIs.
  381. <P>
  382. Nonportable programs may use the APIs of the Sun protocol providers
  383. by (for example) casting a returned <code>Folder</code> object to a
  384. <code>com.sun.mail.imap.IMAPFolder</code> object.  Similarly for
  385. <code>Store</code> and <code>Message</code> objects returned from the
  386. standard JavaMail APIs.
  387. <P>
  388. The Sun protocol providers also support properties that are specific to
  389. those providers.  The package documentation for the
  390. <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>,
  391. and <A HREF="com/sun/mail/smtp/package-summary.html"><CODE>SMTP</CODE></A> packages provide details.
  392. <P>
  393.  
  394. <P>
  395. <HR>
  396.  
  397.  
  398. <!-- ======= START OF BOTTOM NAVBAR ====== -->
  399. <A NAME="navbar_bottom"><!-- --></A>
  400. <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
  401. <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
  402. <TR>
  403. <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
  404. <A NAME="navbar_bottom_firstrow"><!-- --></A>
  405. <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  406.   <TR ALIGN="center" VALIGN="top">
  407.   <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Overview</B></FONT>&nbsp;</TD>
  408.   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <FONT CLASS="NavBarFont1">Package</FONT>&nbsp;</TD>
  409.   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <FONT CLASS="NavBarFont1">Class</FONT>&nbsp;</TD>
  410.   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <FONT CLASS="NavBarFont1">Use</FONT>&nbsp;</TD>
  411.   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="overview-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  412.   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  413.   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  414.   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  415.   </TR>
  416. </TABLE>
  417. </TD>
  418. <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
  419. </EM>
  420. </TD>
  421. </TR>
  422.  
  423. <TR>
  424. <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  425. &nbsp;PREV&nbsp;
  426. &nbsp;NEXT</FONT></TD>
  427. <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  428.   <A HREF="index.html?overview-summary.html" target="_top"><B>FRAMES</B></A>  &nbsp;
  429. &nbsp;<A HREF="overview-summary.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
  430. &nbsp;<SCRIPT type="text/javascript">
  431.   <!--
  432.   if(window==top) {
  433.     document.writeln('<A HREF="allclasses-noframe.html"><B>All Classes</B></A>');
  434.   }
  435.   //-->
  436. </SCRIPT>
  437. <NOSCRIPT>
  438.   <A HREF="allclasses-noframe.html"><B>All Classes</B></A>
  439. </NOSCRIPT>
  440.  
  441.  
  442. </FONT></TD>
  443. </TR>
  444. </TABLE>
  445. <A NAME="skip-navbar_bottom"></A>
  446. <!-- ======== END OF BOTTOM NAVBAR ======= -->
  447.  
  448. <HR>
  449. Copyright &#169; 2009 <a href="http://www.sun.com">Sun Microsystems, Inc.</a>. All Rights Reserved.
  450. </BODY>
  451. </HTML>
  452.