Javamail-api-pop3-servers

提供:Dev Guides
移動先:案内検索

JavaMail API-POP3サーバー

Post Office Protocol(POP)は、TCP/IP接続を介してリモートサーバーから電子メールを取得するためにローカル電子メールクライアントが使用するアプリケーション層のインターネット標準プロトコルです。 POPは、リモートメールボックスにアクセスするための簡単なダウンロードと削除の要件をサポートしています。 POP3サーバーは、既知のポート110でリッスンします。

パッケージ com.sun.mail.pop3 は、POP3メッセージストアへのアクセスを提供するJavaMail APIのPOP3プロトコルプロバイダーです。 次の表に、このパッケージのクラスを示します。

Name Description
POP3Folder A POP3 Folder (can only be "INBOX").
POP3Message A POP3 Message.
POP3SSLStore A POP3 Message Store using SSL.
POP3Store A POP3 Message Store.

このプロバイダーの上に注意すべきいくつかのポイント:

  • POP3プロバイダーは、 INBOX という名前の単一のフォルダーのみをサポートします。 POP3プロトコルの制限により、イベント通知、フォルダー管理、フラグ管理などのJavaMail API機能の多く 許可されていません。
  • POP3プロバイダーには、プロトコル名_pop3_または_pop3://user:password @ host:port/INBOX "_の形式のURLを使用して、JavaMail APIからアクセスします。
  • POP3は永続的なフラグをサポートしていません。 たとえば、_Flags.Flag.RECENT_フラグは、POP3メッセージには設定されません。 POP3メールボックスのどのメッセージが_new_であるかを判断するのはアプリケーション次第です。
  • POP3はFolder.expunge()メソッドをサポートしていません。 メッセージを削除および消去するには、メッセージにFlags.Flag.DELETEDフラグを設定し、Folder.close(true)メソッドを使用してフォルダーを閉じます。
  • POP3は_received date_を提供しないため、getReceivedDateメソッドはnullを返します。
  • POP3メッセージのヘッダーにアクセスすると、POP3プロバイダーはTOPコマンドを使用してすべてのヘッダーを取得し、その後、キャッシュします。
  • POP3メッセージのコンテンツにアクセスすると、POP3プロバイダーはRETRコマンドを使用してメッセージ全体を取得します。
  • _POP3Message.invalidate_メソッドを使用すると、フォルダーを閉じずにキャッシュされたデータを無効にできます。

POP3プロトコルプロバイダーは、JavaMail Sessionオブジェクトで設定できる以下のプロパティをサポートします。 プロパティは常に文字列として設定されます。 「タイプ」列は、ストリングの解釈方法を説明しています。

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. 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.
mail.pop3.localaddress String Local address (host name) to bind to when creating the POP3 socket. Defaults to the address picked by the Socket class.
mail.pop3.localport int Local port number to bind to when creating the POP3 socket. Defaults to the port number picked by the Socket class.
mail.pop3.apop.enable boolean If set to true, use APOP instead of USER/PASS to login to the POP3 server, if the POP3 server supports APOP. APOP sends a digest of the password rather than the clear text password. Defaults to false.
mail.pop3.socketFactory Socket Factory If set to a class that implements the javax.net.SocketFactory interface, this class will be used to create POP3 sockets.
mail.pop3.socketFactory.class String If set, specifies the name of a class that implements the javax.net.SocketFactory interface. This class will be used to create POP3 sockets.
mail.pop3.socketFactory.fallback boolean If set to true, failure to create a socket using the specified socket factory class will cause the socket to be created using the java.net.Socket class. Defaults to true.
mail.pop3.socketFactory.port int Specifies the port to connect to when using the specified socket factory. If not set, the default port will be used.
mail.pop3.ssl.enable boolean If set to true, use SSL to connect and use the SSL port by default. Defaults to false for the "pop3" protocol and true for the "pop3s" protocol.
mail.pop3.ssl.checkserveridentity boolean If set to true, check the server identity as specified by RFC 2595. Defaults to false.
mail.pop3.ssl.trust String If set, and a socket factory hasn’t been specified, enables use of a MailSSLSocketFactory. If set to "*", all hosts are trusted. If set to a whitespace separated list of hosts, those hosts are trusted. Otherwise, trust depends on the certificate the server presents.
mail.pop3.ssl.socketFactory SSL Socket Factory If set to a class that extends the javax.net.ssl.SSLSocketFactory class, this class will be used to create POP3 SSL sockets.
mail.pop3.ssl.socketFactory.class String If set, specifies the name of a class that extends the javax.net.ssl.SSLSocketFactory class. This class will be used to create POP3 SSL sockets.
mail.pop3.ssl.socketFactory.port int Specifies the port to connect to when using the specified socket factory. If not set, the default port will be used.
mail.pop3.ssl.protocols string Specifies the SSL protocols that will be enabled for SSL connections. The property value is a whitespace separated list of tokens acceptable to the javax.net.ssl.SSLSocket.setEnabledProtocols method.
mail.pop3.starttls.enable boolean If true, enables the use of the STLS command (if supported by the server) to switch the connection to a TLS-protected connection before issuing any login commands. Defaults to false.
mail.pop3.starttls.required boolean If true, requires the use of the STLS command. If the server doesn’t support the STLS command, or the command fails, the connect method will fail. Defaults to false.
mail.pop3.socks.host string Specifies the host name of a SOCKS5 proxy server that will be used for connections to the mail server.
mail.pop3.socks.port string Specifies the port number for the SOCKS5 proxy server.
mail.pop3.disabletop boolean If set to true, the POP3 TOP command will not be used to fetch message headers. Defaults to false.
mail.pop3.forgettopheaders boolean If set to true, the headers that might have been retrieved using the POP3 TOP command will be forgotten and replaced by headers retrieved as part of the POP3 RETR command. Defaults to false.
mail.pop3.filecache.enable boolean If set to true, the POP3 provider will cache message data in a temporary file rather than in memory. Messages are only added to the cache when accessing the message content. Message headers are always cached in memory (on demand). The file cache is removed when the folder is closed or the JVM terminates. Defaults to false.
mail.pop3.filecache.dir String If the file cache is enabled, this property can be used to override the default directory used by the JDK for temporary files.
mail.pop3.cachewriteto boolean Controls the behavior of the writeTo method on a POP3 message object. If set to true, and the message content hasn’t yet been cached, and ignoreList is null, the message is cached before being written. Otherwise, the message is streamed directly to the output stream without being cached. Defaults to false.
mail.pop3.keepmessagecontent boolean If this property is set to true, a hard reference to the cached content will be kept, preventing the memory from being reused until the folder is closed or the cached content is explicitly invalidated (using the invalidate method). Defaults to false.

一般に、アプリケーションはこのパッケージのクラスを直接使用しないでください。 代わりに、_javax.mail_パッケージ(およびサブパッケージ)で定義されたAPIを使用する必要があります。 アプリケーションは、_POP3Store_または_POP3Folder_のインスタンスを直接構築しないでください。 代わりに、SessionメソッドgetStoreを使用して適切なStoreオブジェクトを取得し、そこからFolderオブジェクトを取得する必要があります。

POP3サーバーの使用例は、リンク:/javamail_api/javamail_api_checking_emails [Checking Emails]に示されています。