0N/A
0N/A JavaMail 1.3
0N/A ============
0N/A
0N/A (Updated April 1, 2002)
0N/A
0N/AFollowing is a description of the new APIs that are being
0N/Aintroduced in JavaMail 1.3. The numbers in parentheses
0N/Aare bug numbers; you can find more information about the
0N/Abug reports at:
0N/A
0N/A http://developer.java.sun.com/developer/bugParade/index.html
0N/A
0N/APlease send comments and feedback to javamail@sun.com.
0N/A
0N/AMany of these changes expand JavaMail's conformance with Internet
0N/Astandards, or make JavaMail more tolerant of messages that don't
0N/Aquite conform to the standards. "Be liberal in what you receive
0N/Aand conservative in what you send."
0N/A
0N/A
0N/A===================================================================
0N/A
0N/A1. Add setSender and getSender methods to MimeMessage (4405115)
0N/A---------------------------------------------------------------
0N/A
0N/AThese convenience methods support setting and reading the RFC 822
0N/ASender header.
0N/A
0N/A /**
0N/A * Returns the value of the RFC 822 "Sender" header field.
0N/A * If the "Sender" header field is absent, <code>null</code>
0N/A * is returned.<p>
0N/A *
0N/A * This implementation uses the <code>getHeader</code> method
0N/A * to obtain the requisite header field.
0N/A *
0N/A * @return Address object
0N/A * @exception MessagingException
0N/A * @see #headers
0N/A * @since JavaMail 1.3
0N/A */
0N/A public Address getSender() throws MessagingException
0N/A
0N/A /**
0N/A * Set the RFC 822 "Sender" header field. Any existing values are
0N/A * replaced with the given address. If address is <code>null</code>,
0N/A * this header is removed.
0N/A *
0N/A * @param address the sender of this message
0N/A * @exception IllegalWriteException if the underlying
0N/A * implementation does not support modification
0N/A * of existing values
0N/A * @exception IllegalStateException if this message is
0N/A * obtained from a READ_ONLY folder.
0N/A * @exception MessagingException
0N/A * @since JavaMail 1.3
0N/A */
0N/A public void setSender(Address address) throws MessagingException
0N/A
0N/A===================================================================
0N/A
0N/A2. Add setContentID method to MimeBodyPart (4377720)
0N/A----------------------------------------------------
0N/A
0N/AThis convenience method supports setting the Content-ID header.
0N/A
0N/A /**
0N/A * Set the "Content-ID" header field of this body part.
0N/A * If the <code>cid</code> parameter is null, any existing
0N/A * "Content-ID" is removed.
0N/A *
0N/A * @exception IllegalWriteException if the underlying
0N/A * implementation does not support modification
0N/A * @exception IllegalStateException if this body part is
0N/A * obtained from a READ_ONLY folder.
0N/A * @exception MessagingException
0N/A * @since JavaMail 1.3
0N/A */
0N/A public void setContentID(String cid) throws MessagingException
0N/A
0N/A===================================================================
0N/A
0N/A3. Add mail.mime.charset property (4377731)
0N/A-------------------------------------------
0N/A
0N/AThe "mail.mime.charset" System property (NOTE: *not* Session property)
0N/Anames the default charset to be used by JavaMail. If not set, the
0N/Astandard J2SE "file.encoding" System property is used. This allows
0N/Aapplications to specify a default character set for sending messages
0N/Athat's different than the character set used for files stored on the
0N/Asystem. This is common on Japanese systems.
0N/A
0N/A===================================================================
0N/A
0N/A4. Add getDeletedMesageCount method to Folder (4388730)
0N/A-------------------------------------------------------
0N/A
0N/AThis convenience method would return a count of the number of deleted
0N/Amessages in a folder.
0N/A
0N/A /**
0N/A * Get the number of deleted messages in this Folder. <p>
0N/A *
0N/A * This method can be invoked on a closed folder. However, note
0N/A * that for some folder implementations, getting the deleted message
0N/A * count can be an expensive operation involving actually opening
0N/A * the folder. In such cases, a provider can choose not to support
0N/A * this functionality in the closed state, in which case this method
0N/A * must return -1. <p>
0N/A *
0N/A * Clients invoking this method on a closed folder must be aware
0N/A * that this is a potentially expensive operation. Clients must
0N/A * also be prepared to handle a return value of -1 in this case. <p>
0N/A *
0N/A * This implementation returns -1 if this folder is closed. Else
0N/A * this implementation gets each Message in the folder using
0N/A * <code>getMessage(int)</code> and checks whether its
0N/A * <code>DELETED</code> flag is set. The total number of messages
0N/A * that have this flag set is returned.
0N/A *
0N/A * @return number of deleted messages. -1 may be returned
0N/A * by certain implementations if this method is
0N/A * invoked on a closed folder.
0N/A * @exception FolderNotFoundException if this folder does
0N/A * not exist.
0N/A * @exception MessagingException
0N/A * @since JavaMail 1.3
0N/A */
0N/A public int getDeletedMessageCount() throws MessagingException
0N/A
0N/A===================================================================
0N/A
0N/A5. Support parsing "illegal" Internet addresses (4650940)
0N/A---------------------------------------------------------
0N/A
0N/AThe parse method on the InternetAddress class takes a flag that tells
0N/Awhether or not to strictly enforce the RFC822 syntax rules. Currently,
0N/Awhen the flag is false most rules are still checked while a few are not.
0N/ATo better support the range of "invalid" addresses seen in real messages,
0N/Aand in combination with the following two changes, the parseHeader
0N/Amethod would enforce fewer syntax rules when the strict flag is false
0N/Aand would enforce more rules when the strict flag is true. If the
0N/Astrict flag is false and the parse is successful in separating out an
0N/Aemail address or addresses, the syntax of the addresses themselves
0N/Awould not be checked. (Introducing a new method preserves
0N/Acompatibility with users of the existing parse method.)
0N/A
0N/A /**
0N/A * Parse the given sequence of addresses into InternetAddress
0N/A * objects. If <code>strict</code> is false, the full syntax rules for
0N/A * individual addresses are not enforced. If <code>strict</code> is
0N/A * true, many (but not all) of the RFC822 syntax rules are enforced.
0N/A *
0N/A * Non-strict parsing is typically used when parsing a list of
0N/A * mail addresses entered by a human. Strict parsing is typically
0N/A * used when parsing address headers in mail messages.
0N/A *
0N/A * @param addresslist comma separated address strings
0N/A * @param strict enforce RFC822 syntax
0N/A * @return array of InternetAddress objects
0N/A * @exception AddressException if the parse failed
0N/A * @since JavaMail 1.3
0N/A */
0N/A public static InternetAddress[] parseHeader(String s, boolean strict)
0N/A throws AddressException
0N/A
0N/A
0N/ATo allow applications to check the syntax of addresses that might've
0N/Abeen parsed with the strict flag set to false, we add a validate
0N/Amethod.
0N/A
0N/A /**
0N/A * Validate that this address conforms to the syntax rules
0N/A * of RFC 822. The current implementation checks many, not
0N/A * all, syntax rules. Note that, even though the syntax of
0N/A * the address may be correct, there's no guarantee that a
0N/A * mailbox of that name exists.
0N/A *
0N/A * @exception AddressException if the address
0N/A * isn't valid.
0N/A * @since JavaMail 1.3
0N/A */
0N/A public void validate() throws AddressException
0N/A
0N/A
0N/ATo control the strict flag when constructing a single InternetAddress
0N/Aobject we add a new constructor.
0N/A
0N/A /**
0N/A * Parse the given string and create an InternetAddress.
0N/A * If <code>strict</code> is false, the detailed syntax of the
0N/A * address isn't checked.
0N/A *
0N/A * @param address the address in RFC822 format
0N/A * @param strict enforce RFC822 syntax
0N/A * @exception AddressException if the parse failed
0N/A * @since JavaMail 1.3
0N/A */
0N/A public InternetAddress(String address, boolean strict)
0N/A throws AddressException
0N/A
0N/A===================================================================
0N/A
0N/A6. Add mail.mime.address.strict property (4650940)
0N/A--------------------------------------------------
0N/A
0N/AThe MimeMessage class will use the new parseHeader method introduced
0N/Aabove to parse headers in messages. The "mail.mime.address.strict"
0N/ASession property will control the strict flag passed to the parseHeader
0N/Amethod. The default is true.
0N/A
0N/A===================================================================
0N/A
0N/A7. Add mail.mime.decodetext.strict property (4201203)
0N/A-----------------------------------------------------
0N/A
0N/ARFC 2047 requires that encoded text start at the beginning of a
0N/Awhitespace separated word. Some mailers, especially Japanese mailers,
0N/Aimproperly encode text and included encoded text in the middle of words.
0N/AThe "mail.mime.decodetext.strict" System property (NOTE: *not* Session
0N/Aproperty) controls whether JavaMail will attempt to decode such
0N/Aincorrectly encoded text. The default is true.
0N/A
0N/A===================================================================
0N/A
0N/A8. Add mail.mime.encodeeol.strict property (4650949)
0N/A----------------------------------------------------
0N/A
0N/AWhen choosing an encoding for the data of a message, JavaMail assumes
0N/Athat any of CR, LF, or CRLF are valid line terminators in message
0N/Aparts that contain only printable ASCII characters, even if the part is
0N/Anot a MIME text type. It's common, especially on UNIX systems, for
0N/Adata of MIME type application/octet-stream (for example) to really be
0N/Atextual data that should be transmitted with the encoding rules for
0N/AMIME text. In rare cases, such pure ASCII text may in fact be binary
0N/Adata in which the CR and LF characters must be preserved exactly. The
0N/A"mail.mime.encodeeol.strict" System property (NOTE: *not* Session
0N/Aproperty) controls whether JavaMail will consider a lone CR or LF in a
0N/Abody part that's not a MIME text type to indicate that the body part
0N/Aneeds to be encoded.
0N/A
0N/A===================================================================
0N/A
0N/A9. Add isGroup and getGroup methods to InternetAddress (4650952)
0N/A----------------------------------------------------------------
0N/A
0N/ATo better support RFC822 group addresses, the following methods
0N/Awould be added.
0N/A
0N/A /**
0N/A * Indicates whether this address is an RFC 822 group address.
0N/A * Note that a group address is different than the mailing
0N/A * list addresses supported by most mail servers. Group addresses
0N/A * are rarely used; see RFC 822 for details.
0N/A *
0N/A * @return true if this address represents a group
0N/A * @since JavaMail 1.3
0N/A */
0N/A public boolean isGroup()
0N/A
0N/A /**
0N/A * Return the members of a group address. A group may have zero,
0N/A * one, or more members. If this address is not a group, null
0N/A * is returned. The <code>strict</code> parameter controls whether
0N/A * the group list is parsed using strict RFC 822 rules or not.
0N/A * The parsing is done using the <code>parseHeader</code> method.
0N/A *
0N/A * @return array of InternetAddress objects, or null
0N/A * @exception AddressException if the group list can't be parsed
0N/A * @since JavaMail 1.3
0N/A */
0N/A public InternetAddress[] getGroup(boolean strict) throws AddressException
0N/A
0N/A
0N/A===================================================================
0N/A
0N/A10. Support per-session debug output stream (4517686)
0N/A-----------------------------------------------------
0N/A
0N/ATo allow the debugging output for a session to be redirected, we add
0N/Athe following methods to Session.
0N/A
0N/A /**
0N/A * Set the stream to be used for debugging output for this session.
0N/A * If <code>out</code> is null, <code>System.out</code> will be used.
0N/A * Note that debugging output that occurs before any session is created,
0N/A * as a result of setting the <code>mail.debug</code> system property,
0N/A * will always be sent to <code>System.out</code>.
0N/A *
0N/A * @param out the PrintStream to use for debugging output
0N/A * @since JavaMail 1.3
0N/A */
0N/A public void setDebugOut(PrintStream out)
0N/A
0N/A /**
0N/A * Returns the stream to be used for debugging output. If no stream
0N/A * has been set, <code>System.out</code> is returned.
0N/A *
0N/A * @return the PrintStream to use for debugging output
0N/A * @since JavaMail 1.3
0N/A */
0N/A public PrintStream getDebugOut()