Class Pop3EmailReceiver
java.lang.Object
cloud.opencode.base.email.receiver.Pop3EmailReceiver
- All Implemented Interfaces:
AutoCloseable
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 Summary
ConstructorsConstructorDescriptionPop3EmailReceiver(EmailReceiveConfig config) Create POP3 receiver with configuration 使用配置创建POP3接收器 -
Method Summary
Modifier and TypeMethodDescriptiondefault voidclose()Close the receiver (alias for disconnect) 关闭接收器(disconnect的别名)voidconnect()voidvoidintgetMessageCount(String folder) intgetUnreadCount(String folder) booleanvoidmarkAsRead(String messageId) voidmarkAsUnread(String messageId) voidmoveToFolder(String messageId, String targetFolder) receive(EmailQuery query) default List<ReceivedEmail> Receive all emails from default folder 从默认文件夹接收所有邮件receiveById(String messageId) voidsetFlagged(String messageId, boolean flagged)
-
Constructor Details
-
Pop3EmailReceiver
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
-
receive
-
receiveById
-
getMessageCount
-
getUnreadCount
-
markAsRead
-
markAsUnread
-
setFlagged
-
delete
-
moveToFolder
-
listFolders
-
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:
closein interfaceAutoCloseable
-