public class ImapPop3EmailService extends Object implements InboundEmailService
| Constructor and Description |
|---|
ImapPop3EmailService(String server,
InboundEmailProtocol protocol,
String secret) |
| Modifier and Type | Method and Description |
|---|---|
EmailMessage |
copyMessage(EmailMessage message,
String targetFolder)
Makes a copy of given email message in the specified folder.
|
boolean |
createFolder(String folderName)
Creates a new folder with given name in the mailbox.
|
boolean |
deleteFolder(String folderName)
Deletes given mailbox folder with all messages and sub-folders contained in it.
|
void |
deleteMessage(EmailMessage message)
Deletes given email message from the mailbox.
|
void |
deleteMessages(List<EmailMessage> messages)
Deletes given email messages from the mailbox.
|
List<EmailMessage> |
fetchAllMessages(Predicate<EmailMessage> isSatisfy)
Gets all email messages contained in all mailbox folders and satisfy to specific condition.
|
EmailMessage |
fetchMessage(String messageId)
Searches email message in the mailbox with given message ID.
|
List<EmailMessage> |
fetchMessages(String folderName,
Predicate<EmailMessage> isSatisfy)
Gets email messages contained in the mailbox folder with given name and satisfy to specific condition.
|
List<EmailMessage> |
fetchUnreadMessages(String folderName,
boolean markRead)
Gets unread messages contained in the mailbox folder with given name.
|
int |
getBatchSize() |
String |
getHost() |
MessageConverter<javax.mail.Message> |
getMessageConverter() |
int |
getMessageCount(String folderName)
Gets amount of email messages in the mailbox folder with given name.
|
String |
getPort() |
InboundEmailProtocol |
getProtocol() |
javax.mail.Session |
getSession() |
javax.mail.Store |
getStore() |
List<String> |
listFolders()
Gets the list of folder names that are present in the mailbox.
|
EmailMessage |
moveMessage(EmailMessage message,
String targetFolder)
Moves given email message to the specified folder.
|
boolean |
renameFolder(String folderName,
String newFolderName)
Renames given mailbox folder.
|
void |
setBatchSize(int batchSize) |
void |
setMessageConverter(MessageConverter<javax.mail.Message> messageConverter) |
void |
updateMessage(EmailMessage message)
Updates parameters of given email message in the mailbox.
|
void |
updateMessages(List<EmailMessage> messages)
Updates parameters of given email messages in the mailbox.
|
CompletableFuture<List<EmailMessage>> |
waitMessages(String folderName,
Predicate<EmailMessage> isSatisfy,
Duration timeout,
Duration checkInterval)
Waits appearing of email messages in the mailbox folder with given name that satisfy to specific condition.
|
public ImapPop3EmailService(String server, InboundEmailProtocol protocol, String secret)
public String getHost()
public String getPort()
public InboundEmailProtocol getProtocol()
public javax.mail.Session getSession()
public javax.mail.Store getStore()
public MessageConverter<javax.mail.Message> getMessageConverter()
public void setMessageConverter(MessageConverter<javax.mail.Message> messageConverter)
public int getBatchSize()
public void setBatchSize(int batchSize)
public int getMessageCount(String folderName)
InboundEmailServicegetMessageCount in interface InboundEmailServicefolderName - the name of mailbox folder where is necessary to count messages.public EmailMessage fetchMessage(String messageId)
InboundEmailServiceIt views all mailbox folders to find the necessary message.
fetchMessage in interface InboundEmailServicemessageId - the unique identifier of email message that is necessary to find.EmailMessage object representing found email message or null if nothing is found.public List<EmailMessage> fetchMessages(String folderName, Predicate<EmailMessage> isSatisfy)
InboundEmailServicefetchMessages in interface InboundEmailServicefolderName - the name of mailbox folder where is necessary to collect email messages.isSatisfy - lambda expression representing specific condition. It should return true to let
email message get into results.EmailMessage objects representing satisfying email messages.public List<EmailMessage> fetchAllMessages(Predicate<EmailMessage> isSatisfy)
InboundEmailServicefetchAllMessages in interface InboundEmailServiceisSatisfy - lambda expression representing specific condition. It should return true to let
email message get into results.EmailMessage objects representing satisfying email messages.public List<EmailMessage> fetchUnreadMessages(String folderName, boolean markRead)
InboundEmailServicefetchUnreadMessages in interface InboundEmailServicefolderName - the name of mailbox folder where is necessary to search unread messages.markRead - whether is necessary to mark all found unread messages as read immediately.EmailMessage objects representing unread email messages.public CompletableFuture<List<EmailMessage>> waitMessages(String folderName, Predicate<EmailMessage> isSatisfy, Duration timeout, Duration checkInterval)
InboundEmailServicewaitMessages in interface InboundEmailServicefolderName - the name of mailbox folder where is necessary to check messages.isSatisfy - lambda expression representing specific condition. It should return true to let
email message get into results.timeout - the maximum time of waiting necessary messages.checkInterval - amount of time that defines period of checking newly come messages.CompletableFuture object with list of EmailMessage objects representing satisfying email
messages as result.public EmailMessage copyMessage(EmailMessage message, String targetFolder)
InboundEmailServicecopyMessage in interface InboundEmailServicemessage - the source email message that should be copied.targetFolder - the name of mailbox folder where the email message should be copied.EmailMessage object representing copied message.public EmailMessage moveMessage(EmailMessage message, String targetFolder)
InboundEmailServicemoveMessage in interface InboundEmailServicemessage - the source email message that should be moved.targetFolder - the name of mailbox folder where the email message should be moved.EmailMessage object representing moved message. The source message will be deleted.public void updateMessage(EmailMessage message)
InboundEmailServiceupdateMessage in interface InboundEmailServicemessage - the email message whose parameters should be updated in the mailbox.public void updateMessages(List<EmailMessage> messages)
InboundEmailServiceupdateMessages in interface InboundEmailServicemessages - the list of email messages whose parameters should be updated in the mailbox.public void deleteMessage(EmailMessage message)
InboundEmailServiceThe message is deleted permanently without Trash.
deleteMessage in interface InboundEmailServicemessage - the email message to delete.public void deleteMessages(List<EmailMessage> messages)
InboundEmailServiceMessages are deleted permanently without Trash.
deleteMessages in interface InboundEmailServicemessages - the list of email messages to delete.public List<String> listFolders()
InboundEmailServicelistFolders in interface InboundEmailServicepublic boolean createFolder(String folderName)
InboundEmailServicecreateFolder in interface InboundEmailServicefolderName - the name of folder to create.true if the folder has been created successfully and false otherwise.public boolean renameFolder(String folderName, String newFolderName)
InboundEmailServicerenameFolder in interface InboundEmailServicefolderName - the name of source mailbox folder.newFolderName - a new name of the folder.true if the folder has been renamed successfully and false otherwise.public boolean deleteFolder(String folderName)
InboundEmailServicedeleteFolder in interface InboundEmailServicefolderName - the name of mailbox folder to delete.true if the folder has been deleted successfully and false otherwise.Copyright © 2023. All rights reserved.