Class Pop3EmailReceiver

java.lang.Object
cloud.opencode.base.email.receiver.Pop3EmailReceiver
All Implemented Interfaces:
AutoCloseable

public class Pop3EmailReceiver extends Object
POP3 Email Receiver Implementation POP3邮件接收器实现

Receives emails using POP3 protocol.

使用POP3协议接收邮件。

Features | 主要功能:

  • POP3/POP3S support - POP3/POP3S支持
  • Basic message retrieval - 基本消息检索
  • Delete support - 删除支持
  • Attachment handling - 附件处理

Limitations | 限制:

  • No folder support (INBOX only) - 无文件夹支持(仅INBOX)
  • No server-side search - 无服务器端搜索
  • No flag persistence - 无标记持久化
  • No move operations - 无移动操作

Usage Examples | 使用示例:

EmailReceiveConfig config = EmailReceiveConfig.builder()
    .host("pop.example.com")
    .username("user@example.com")
    .password("password")
    .pop3()
    .ssl(true)
    .build();

try (Pop3EmailReceiver receiver = new Pop3EmailReceiver(config)) {
    receiver.connect();
    List<ReceivedEmail> emails = receiver.receiveAll();
    for (ReceivedEmail email : emails) {
        processEmail(email);
    }
}

Security | 安全性:

  • Thread-safe: No (use one instance per thread) - 线程安全: 否(每线程使用一个实例)
Since:
JDK 25, opencode-base-email V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • Pop3EmailReceiver

      public Pop3EmailReceiver(EmailReceiveConfig config)
      Create POP3 receiver with configuration 使用配置创建POP3接收器
      Parameters:
      config - the receive configuration | 接收配置
  • Method Details

    • connect

      public void connect()
    • disconnect

      public void disconnect()
    • isConnected

      public boolean isConnected()
    • receiveUnread

      public List<ReceivedEmail> receiveUnread()
    • receive

      public List<ReceivedEmail> receive(EmailQuery query)
    • receiveById

      public ReceivedEmail receiveById(String messageId)
    • getMessageCount

      public int getMessageCount(String folder)
    • getUnreadCount

      public int getUnreadCount(String folder)
    • markAsRead

      public void markAsRead(String messageId)
    • markAsUnread

      public void markAsUnread(String messageId)
    • setFlagged

      public void setFlagged(String messageId, boolean flagged)
    • delete

      public void delete(String messageId)
    • moveToFolder

      public void moveToFolder(String messageId, String targetFolder)
    • listFolders

      public List<String> listFolders()
    • receiveAll

      default List<ReceivedEmail> receiveAll()
      Receive all emails from default folder 从默认文件夹接收所有邮件
      Returns:
      list of received emails | 接收到的邮件列表
    • close

      default void close()
      Close the receiver (alias for disconnect) 关闭接收器(disconnect的别名)
      Specified by:
      close in interface AutoCloseable