Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES

## Package com.sun.mail.pop3

A POP3 protocol provider for the JavaMail API that provides access to a POP3 message store.

See:
Description

Class Summary
POP3Folder | A POP3 Folder (can only be "INBOX").
POP3Message | A POP3 Message.
POP3Store | A POP3 Message Store.

## Package com.sun.mail.pop3 Description

A POP3 protocol provider for the JavaMail API that provides access to a POP3 message store. Refer to RFC 1939 for more information.

The POP3 provider provides a Store object that contains a single Folder named "INBOX". Due to the limitations of the POP3 protocol, many of the JavaMail API capabilities like event notification, folder management, flag management, etc. are not allowed. The corresponding methods throw the MethodNotSupportedException exception; see below for details.

Note that JavaMail does not include a local store into which messages can be downloaded and stored. See our Third Party Products web page for availability of "mbox" and "MH" local store providers.

The POP3 provider is accessed through the JavaMail APIs by using the protocol name "pop3" or a URL of the form "pop3://user:password@host:port/INBOX".

POP3 supports only a single folder named "INBOX".

POP3 supports no permanent flags (see `Folder.getPermanentFlags()`). In particular, the `Flags.Flag.RECENT` flag will never be set for POP3 messages. It's up to the application to determine which messages in a POP3 mailbox are "new". There are several strategies to accomplish this, depending on the needs of the application and the environment:

- A simple approach would be to keep track of the newest message seen by the application.
- An alternative would be to keep track of the UIDs (see below) of all messages that have been seen.
- Another approach is to download all messages into a local mailbox, so that all messages in the POP3 mailbox are, by definition, new.

All approaches will require some permanent storage associated with the client.

POP3 does not support the `Folder.expunge()` method. To delete and expunge messages, set the `Flags.Flag.DELETED` flag on the messages and close the folder using the `Folder.close(true)` method. You cannot expunge without closing the folder.

POP3 does not provide a "received date", so the `getReceivedDate` method will return null. It may be possible to examine other message headers (e.g., the "Received" headers) to estimate the received date, but these techniques are error-prone at best.

The POP3 provider supports the POP3 UIDL command, see `POP3Folder.getUID()`. You can use it as follows:

>     if (folder instanceof com.sun.mail.pop3.POP3Folder) {
>         com.sun.mail.pop3.POP3Folder pf =
>     	(com.sun.mail.pop3.POP3Folder)folder;
>         String uid = pf.getUID(msg);
>         if (uid != null)
>     	... // use it
>     }

You can also pre-fetch all the UIDs for all messages like this:

>     FetchProfile fp = new FetchProfile();
>     fp.add(UIDFolder.FetchProfileItem.UID);
>     folder.fetch(folder.getMessages(), fp);

Then use the technique above to get the UID for each message. This is similar to the technique used with the UIDFolder interface supported by IMAP, but note that POP3 UIDs are strings, not integers like IMAP UIDs. See the POP3 spec for details.

The POP3 protocol provider supports the following properties, which may be set in the JavaMail `Session` object. The properties are always set as strings; the Type column describes how the string is interpreted. For example, use

    	props.put("mail.pop3.port", "888");

to set the `mail.pop3.port` property, which is of type int.

Name | Type | Description
--- | --- | ---
mail.pop3.user | String | Default user name for POP3.
mail.pop3.host | String | The POP3 server to connect to.
mail.pop3.port | int | The POP3 server port to connect to, if the connect() method doesn't explicitly specify one. Defaults to 110.
mail.pop3.connectiontimeout | int | Socket connection timeout value in milliseconds. Default is infinite timeout.
mail.pop3.timeout | int | Socket I/O timeout value in milliseconds. Default is infinite timeout.
mail.pop3.rsetbeforequit | boolean | Send a POP3 RSET command when closing the folder, before sending the QUIT command. Useful with POP3 servers that implicitly mark all messages that are read as "deleted"; this will prevent such messages from being deleted and expunged unless the client requests so. Default is false.
mail.pop3.message.class | String | Class name of a subclass of `com.sun.mail.pop3.POP3Message`. The subclass can be used to handle (for example) non-standard Content-Type headers. The subclass must have a public constructor of the form `MyPOP3Message(Folder f, int msgno) throws MessagingException`.

In general, applications should not need to use the classes in this package directly. Instead, they should use the APIs defined by `javax.mail` package (and subpackages). Applications should never construct instances of `POP3Store` or `POP3Folder` directly. Instead, they should use the `Session` method `getStore` to acquire an appropriate `Store` object, and from that acquire `Folder` objects.

WARNING: The APIs unique to this package should be considered EXPERIMENTAL. They may be changed in the future in ways that are incompatible with applications using the current APIs.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES