1 JavaMail API TM Design Specification Version 1.5 Send feedback to [email protected] Oracle America, Inc. March 2013 Rev A 500 Oracle Parkway Redwood City, California 94065, U.S.A. Specification: JSR-919 JavaMail(TM) Specification ("Specification") Version: 1.5 Status: Final Release Specification Lead: Oracle America, Inc. ("Specification Lead") Release: 31 May 2013 Copyright 2013 Oracle America, Inc. All rights reserved. LIMITED LICENSE GRANTS 1. License for Evaluation Purposes. Specification Lead hereby grants you a fully-paid, non-exclusive, non-transferable, worldwide, limited license (without the right to sublicense), under Specification Lead’s applicable intellectual property rights to view, download, use and reproduce the Specification only for the purpose of internal evaluation. This includes (i) developing applications intended to run on an implementation of the Specification, provided that such applications do not themselves implement any portion(s) of the Specification, and (ii) discussing the Specification with any third party; and (iii) excerpting brief portions of the Specification in oral or written communications which discuss the Specification provided that such excerpts do not in the aggregate constitute a significant portion of the Specification. 2. License for the Distribution of Compliant Implementations. Specification Lead also grants you a perpetual, non-exclusive, non-transferable, worldwide, fully paid-up, royalty free, limited license (without the right to sublicense) under any applicable copyrights or, subject to the provisions of subsection 4 below, patent rights it may have covering the Specification to create and/or distribute an Independent Implementation of the Specification that: (a) fully implements the Specification including all its required interfaces and functionality; (b) does not modify, subset, superset or otherwise extend the Licensor Name Space, or include any public or protected packages, classes, Java interfaces, fields or methods within the Licensor Name Space other than those required/authorized by the Specification or Specifications being implemented; and (c) passes the Technology Compatibility Kit (including satisfying the requirements of the applicable TCK Users Guide) for such Specification ("Compliant Implementation"). In addition, the foregoing license is expressly conditioned on your not acting outside its scope. No license is granted hereunder for any other purpose (including, for example, modifying the Specification, other than to the extent of your fair use rights, or distributing the Specification to third parties). Also, no right, title, or interest in or to any trademarks, service marks, or trade names of Specification Lead or Specification Lead’s licensors is granted hereunder. Java, and Java-related logos, marks and names are trademarks or registered trademarks of Oracle America, Inc. in the U.S. and other countries. 3. Pass-through Conditions. You need not include limitations (a)-(c) from the previous paragraph or any other particular "pass through" requirements in any license You grant concerning the use of your Independent Implementation or products derived from it. However, except with respect to Independent Implementations (and products derived from them) that satisfy limitations (a)-(c) from the previous paragraph, You may neither: (a) grant or otherwise pass through to your licensees any licenses under Specification Lead’s applicable intellectual property rights; nor (b) authorize your licensees to make any claims concerning their implementation’s compliance with the Specification in question. 4. Reciprocity Concerning Patent Licenses. a. With respect to any patent claims covered by the license granted under subparagraph 2 above that would be infringed by all technically feasible implementations of the Specification, such license is conditioned upon your offering on fair, reasonable and non-discriminatory terms, to any party seeking it from You, a perpetual, non-exclusive, non-transferable, worldwide license under Your patent rights which are or would be infringed by all technically feasible implementations of the Specification to develop, distribute and use a Compliant Implementation. b With respect to any patent claims owned by Specification Lead and covered by the license granted under subparagraph 2, whether or not their infringement can be avoided in a technically feasible manner when implementing the Specification, such license shall terminate with respect to such claims if You initiate a claim against Specification Lead that it has, in the course of performing its responsibilities as the Specification Lead, induced any other entity to infringe Your patent rights. c Also with respect to any patent claims owned by Specification Lead and covered by the license granted under subparagraph 2 above, where the infringement of such claims can be avoided in a technically feasible manner when implementing the Specification such license, with respect to such claims, shall terminate if You initiate a claim against Specification Lead that its making, having made, using, offering to sell, selling or importing a Compliant Implementation infringes Your patent rights. 5. Definitions. For the purposes of this Agreement: "Independent Implementation" shall mean an implementation of the Specification that neither derives from any of Specification Lead’s source code or binary code materials nor, except with an appropriate and separate license from Specification Lead, includes any of Specification Lead’s source code or binary code materials; "Licensor Name Space" shall mean the public class or interface declarations whose names begin with "java", "javax", "com.<Specification Lead>" or their equivalents in any subsequent naming convention adopted by Oracle through the Java Community Process, or any recognized successors or replacements thereof; and "Technology Compatibility Kit" or "TCK" shall mean the test suite and accompanying TCK March 2013 User’s Guide provided by Specification Lead which corresponds to the Specification and that was available either (i) from Specification Lead’s 120 days before the first release of Your Independent Implementation that allows its use for commercial purposes, or (ii) more recently than 120 days from such release but against which You elect to test Your implementation of the Specification. This Agreement will terminate immediately without notice from Specification Lead if you breach the Agreement or act outside the scope of the licenses granted above. DISCLAIMER OF WARRANTIES THE SPECIFICATION IS PROVIDED "AS IS". SPECIFICATION LEAD MAKES NO REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT (INCLUDING AS A CONSEQUENCE OF ANY PRACTICE OR IMPLEMENTATION OF THE SPECIFICATION), OR THAT THE CONTENTS OF THE SPECIFICATION ARE SUITABLE FOR ANY PURPOSE. This document does not represent any commitment to release or implement any portion of the Specification in any product. In addition, the Specification could include technical inaccuracies or typographical errors. LIMITATION OF LIABILITY TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL SPECIFICATION LEAD OR ITS LICENSORS BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION, LOST REVENUE, PROFITS OR DATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF OR RELATED IN ANY WAY TO YOUR HAVING, IMPELEMENTING OR OTHERWISE USING USING THE SPECIFICATION, EVEN IF SPECIFICATION LEAD AND/OR ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. You will indemnify, hold harmless, and defend Specification Lead and its licensors from any claims arising or resulting from: (i) your use of the Specification; (ii) the use or distribution of your Java application, applet and/or implementation; and/or (iii) any claims that later versions or releases of any Specification furnished to you are incompatible with the Specification provided to you under this license. RESTRICTED RIGHTS LEGEND U.S. Government: If this Specification is being acquired by or on behalf of the U.S. Government or by a U.S. Government prime contractor or subcontractor (at any tier), then the Government’s rights in the Software and accompanying documentation shall be only as set forth in this license; this is in accordance with 48 C.F.R. 227.7201 through 227.7202-4 (for Department of Defense (DoD) acquisitions) and with 48 C.F.R. 2.101 and 12.212 (for non-DoD acquisitions). REPORT If you provide Specification Lead with any comments or suggestions concerning the Specification ("Feedback"), you hereby: (i) agree that such Feedback is provided on a non-proprietary and non-confidential basis, and (ii) grant Specification Lead a perpetual, non-exclusive, worldwide, fully paid-up, irrevocable license, with the right to sublicense through multiple levels of sublicensees, to incorporate, disclose, and use without limitation the Feedback for any purpose. GENERAL TERMS Any action related to this Agreement will be governed by California law and controlling U.S. federal law. The U.N. Convention for the International Sale of Goods and the choice of law rules of any jurisdiction will not apply. The Specification is subject to U.S. export control laws and may be subject to export or import regulations in other countries. Licensee agrees to comply strictly with all such laws and regulations and acknowledges that it has the responsibility to obtain such licenses to export, re-export or import as may be required after delivery to Licensee. This Agreement is the parties’ entire agreement relating to its subject matter. It supersedes all prior or contemporaneous oral or written communications, proposals, conditions, representations and warranties and prevails over any conflicting or additional terms of any quote, order, acknowledgment, or other communication between the parties relating to its subject matter during the term of this Agreement. No modification to this Agreement will be binding, unless in writing and signed by an authorized representative of each party. Rev. April, 2006 March 2013 March 2013 Contents iii Contents C hapter 1: I ntroduction 1 Targ et Audience 1 A cknowledgments 1 C hapter 2: G oals and Design Principles 3 C hapter 3: A rchitectural Overview 5 JavaMail Layered Architecture 5 JavaMail Class Hierar chy 7 T he JavaMail Framework 8 M ajor JavaMail API Components 10 The Message Class 10 M essage Storage and Retrieval 10 Message Composition and Tr ansport 11 The Session Class 11 T he JavaMail Event Model 11 U sing the JavaMail API 12 C hapter 4: T he Message Class 13 T he Part Interface 16 M essage Attributes 16 The ContentT ype Attribute 17 The Addre ss Class 18 T he BodyPart Class 18 T he Multipart Class 19 T he Flags Class 22 Message Creation And Tr ansmission 23 C hapter 5: T he Mail Session 25 JavaMail™ API Design Specif ication March 2013 i v Contents The Pro vider Registry 26 Resourc e Files 26 Pro vider 28 Pro tocol Selection and Defaults 28 E xample Scenarios 29 M anaging Security 30 Store and Folder URLs 31 C hapter 6: M essage Storage And Retrieval 33 The Store Class 33 Store Events 34 The Folder Class 34 The FetchProfile Method 35 Folder Events 36 The Expunge Pro cess 37 The Search Pro cess 39 C hapter 7: T he JavaBeans Activation Framework 41 A ccessing the Content 41 E xample: Message Output 42 O perating on the Content 43 E xample: Viewing a Message 43 E xample: Showing Attachments 43 Adding Support for Content Ty pes 44 C hapter 8: M essage Composition 45 B uilding a Message Object 45 Message Cr eation 45 S etting Message Attributes 46 S etting Message Content 47 Building a MIME Multipart Message 48 C hapter 9: Tr ansport Protocols and Mechanisms 51 Obtaining the Tr ansport Object 51 Tr ansport Methods 51 Tr ansport Events 52 C onnectionEvent 52 March 2013 JavaMail™ API Design Specification Contents v Tr ansportEvent 53 Using The Tr ansport Class 54 C hapter 10: I nternet Mail 55 The MimeMessage Class 56 The MimeBodyPart Class 57 The MimeMultipart Class 58 The MimeUtility Class 58 C ontent Encoding and Decoding 59 H eader Encoding and Decoding 59 The ContentType Class 60 A ppendix A : E nvironment Properties 61 A ppendix B : E xamples Using the JavaMail API 63 E xample: Showing a Message 63 E xample: Listing Folders 71 Example: Searc h a Folder for a Message 74 E xample: Monitoring a Mailbox 79 E xample: Sending a Message 80 A ppendix C : M essage Security 83 O verview 83 D isplaying an Encrypted/Signed Message 83 M ultiPartEncrypted/Signed Classes 83 R eading the Contents 84 Verifying Signature s 84 Cre ating a Message 85 A ppendix D : P art and Multipart Class Diagram 87 A ppendix E : M imeMessage Object Hierarchy 89 A ppendix F : F eatures Added in JavaMail 1.1 91 The MessageContext Class and MessageAware Interface 91 JavaMail™ API Design Specif ication March 2013 v i Contents The getMessageID method 91 Additions to the InternetAddress Class 92 Additions to the MimeUtility Class 92 New S earchTerms 92 Additions to the Folder Class 93 New Service Class 93 A ppendix G : F eatures Added in JavaMail 1.2 95 Additions to the MimeMessage Class 95 Additions to the MimeMultipart Class 96 The getRawInputStream method 96 Additions to the InternetAddress Class 96 The MailDateFormat Class 97 Additions to Exceptions and Events 97 Additions to the Session Class 98 Additions to the MimeUtility Class 98 Additions for serializable javax.mail.search terms 98 Additions to the Store Class 99 New ContentDisposition Class 99 New performance impr ovements 100 Additions to the ParameterList class 100 A ppendix H : F eatures Added in JavaMail 1.3 101 Add setSender and getSender methods to MimeMessage (440511 5) 101 Add setContentID method to MimeBodyPart (4377720) 102 Add mail.mime.charset pro perty (4377731) 102 Add getDeletedMesageCount method to Folder (4388730) 102 Support parsing illegal Internet addre sses (4650940) 103 Add mail.mime.address.strict pro perty (4650940) 104 Add mail.mime.decodetext.strict pro perty (4201203) 105 Add mail.mime.encodeeol.strict pr operty (4650949) 105 Add isGroup and getGroup methods to InternetAddress (4650952) 105 Support per-session debug output str eam (4517686) 106 A ppendix I : F eatures Added in JavaMail 1.4 107 Add MimePart.setText(text, charset, subtype) method (6300765) 107 Add mail.mime.encodefilename and decodefilename pro perties (6300768) 108 March 2013 JavaMail™ API Design Specification Contents vii Add Service.connect(user, password) (6300771) 108 Add mail.mime.multipart.ignoremissingendboundary System property ( 4971381) 109 Add MimeMultipart.isComplete() method (6300811 ) 110 Add mail.mime.multipart.ignoremissingboundaryparameter property ( 6300814) 110 Add MimeMultipart getPreamble and setPreamble methods (6300828) 111 Add MimeMessage.updateMessageID() pr otected method (6300831) 111 Add MimeMessage.createMimeMessage() pr otected method (6300833) 112 Make the part field of MimePartDataSource pro tected (6300834) 112 Folder.getSeparator should not require the folder to exist (6301381) 113 Add PreencodedMimeBodyPart class (6301386) 113 Add MimeBodyPart attachFile and saveFile methods (6301390) 114 Add MimeUtility fold and unfold methods (630211 8) 115 Allow more control over headers in InternetHeaders object (6302832) 116 Allow applications to dynamically register new protocol pr oviders (6302835) 116 Allow applications to dynamically register addr ess type mappings (4377727) 117 ParameterList class should support non US-ASCII parameters (4107342) 117 Standard interface for Store s that support quotas (6304051) 118 Add ByteArrayDataSource class (4623517) 120 Add SharedByteArrayInputStream class (6304189) 122 Add SharedFileInputStream class (6304193) 123 A ppendix J : F eatures Added in JavaMail 1.5 129 Add FetchProfile.Item.SIZE (5682) 129 Fix protected fields in final classes in javax.mail.search (5683) 129 Add MimeMultipart(String subtype, BodyPart... bps) constr uctor (5684) 130 E xceptions should support exception chaining (5685) 130 ParameterList needs to support use by IMAP (5686) 133 ContentType and ContentDisposition toString should never return null ( 5687) 133 Add Transport.send(msg, username, password) method (5689) 134 8. Add MimeMessage.setFrom(String) method (5690) 135 Add Message.getSesssion() method (5691) 135 MimeBodyPart.attachFile should set the disposition to ATTACHMENT (5692) 136 Add MimeMessage.reply(replyToAll, setAnswered) method (5693) 137 Add additional “next” methods to HeaderTokenizer (5694) 137 Add @MailSessionDefinition and @MailSessionDefinitions for Java EE 7 ( 5743) 138 Make cachedContent field protected in MimeMessage and MimeBodyPart (5769) 140 JavaMail™ API Design Specif ication March 2013 v iii Contents Make MimeMultipart fields pro tected to allow subclassing (5770) 141 N eed simple way to override MIME type and encoding of attachment (5818) 143 E nable RFC 2231 support by default (5819) 145 March 2013 JavaMail™ API Design Specification
Description: