全屏

邮局协议(POP)是使用本地电子邮件客户端可以检索电子邮件从远程服务器通过TCP/ IP连接的应用层网络标准协议。 POP支持访问远程邮箱简单的下载和 - 删除要求。一个POP3服务器监听熟知端口110。

软件包com.sun.mail.pop3是POP3协议提供的JavaMail API,它提供了访问的POP3邮件存储。下表列出了类此包中:

名称描述
POP3FolderA POP3 Folder (can only be "INBOX").
POP3MessageA POP3 Message.
POP3SSLStoreA POP3 Message Store using SSL.
POP3StoreA POP3 Message Store.

有几点要注意此提供以上:

  • POP3提供程序只支持一个名为INBOX一个文件夹。由于POP3协议的限制,许多像事件通知,文件夹管理,标志管理等JavaMail的API的功能是不允许的。

  • POP3提供通过的JavaMail API的使用协议名称POP3或以下形式的URL访问 pop3://user:password@host:port/INBOX".

  • POP3支持没有永久的标志。例如,Flags.Flag.RECENT标志将永远不会被用于POP3邮件设置。它是由应用程序,以确定哪些是在一个POP3邮箱的新邮件。

  • POP3不支持Folder.expunge()方法。删除并抹去消息,请将Flags.Flag.DELETED标志上的信息,并使用Folder.close(true)方法关闭文件夹。

  • POP3不提供接收日期,所以getReceivedDate方法将返回null。

  • 当被访问的POP3邮件的标题,在POP3提供程序使用top命令来获取所有标题,然后将其缓存。

  • 当访问一个POP3邮件的内容时,POP3提供程序使用RETR命令来获取整个消息。

  • POP3Message.invalidate方法可用于缓存的无效数据,但不关闭文件夹。

POP3协议提供程序支持以下属性,这些属性可以在JavaMail会话对象进行设置。该属性始终设置为字符串;类型列描述字符串是如何解释的。

名称类型描述
mail.pop3.userStringDefault user name for POP3.
mail.pop3.hostStringThe POP3 server to connect to.
mail.pop3.portintThe POP3 server port to connect to, if the connect() method doesn't explicitly specify one. Defaults to 110.
mail.pop3.connectiontimeoutintSocket connection timeout value in milliseconds. Default is infinite timeout.
mail.pop3.timeoutintSocket I/O timeout value in milliseconds. Default is infinite timeout.
mail.pop3.rsetbeforequitbooleanSend a POP3 RSET command when closing the folder, before sending the QUIT command. Default is false.
mail.pop3.message.classStringClass 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.localaddressStringLocal address (host name) to bind to when creating the POP3 socket. Defaults to the address picked by the Socket class.
mail.pop3.localportintLocal port number to bind to when creating the POP3 socket. Defaults to the port number picked by the Socket class.
mail.pop3.apop.enablebooleanIf 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.socketFactorySocketFactoryIf set to a class that implements the javax.net.SocketFactory interface, this class will be used to create POP3 sockets.
mail.pop3.socketFactory.classStringIf 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.fallbackbooleanIf 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.portintSpecifies the port to connect to when using the specified socket factory. If not set, the default port will be used.
mail.pop3.ssl.enablebooleanIf 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.checkserveridentitybooleanIf set to true, check the server identity as specified by RFC 2595. Defaults to false.
mail.pop3.ssl.trustStringIf 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.socketFactorySSLSocketFactoryIf 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.classStringIf 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.portintSpecifies the port to connect to when using the specified socket factory. If not set, the default port will be used.






mail.pop3.ssl.protocolsstringSpecifies 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.enablebooleanIf 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.requiredbooleanIf 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.hoststringSpecifies the host name of a SOCKS5 proxy server that will be used for connections to the mail server.
mail.pop3.socks.portstringSpecifies the port number for the SOCKS5 proxy server.
mail.pop3.disabletopbooleanIf set to true, the POP3 TOP command will not be used to fetch message headers. Defaults to false.
mail.pop3.forgettopheadersbooleanIf 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.enablebooleanIf 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.dirStringIf the file cache is enabled, this property can be used to override the default directory used by the JDK for temporary files.
mail.pop3.cachewritetobooleanControls 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.keepmessagecontentbooleanIf 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获得适当的存储对象,并从获取文件夹对象。

示例使用的POP3服务器是体现在 检查电子邮件.


分类导航
点击按住视频可拖动

缩小

关闭

  • 正在学习
  • 北京总部地址:北京市海淀区西三旗街道建材城西路中腾建华商务大厦东侧二层尚学堂
  • 咨询电话:400-009-1906 010-56233821
  • Copyright 2007-2015 北京尚学堂科技有限公司
  • 京ICP备13018289号-1 京公网安备11010802015183