Package de.aikiit.mailclena.mail
Class MailClient
java.lang.Object
de.aikiit.mailclena.mail.MailClient
Encapsulates technical access to mail inbox based on the given application/mail configuration.
-
Nested Class Summary
Modifier and TypeClassDescription(package private) static enum
Encapsulates available application commands for MailClena. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondelete()
Application option to delete existing messages.void
Execute the given command or print an error message if the command is unknown.(package private) long
list()
Shows a list of messages in the mailbox root folder.(package private) Optional
<org.apache.commons.lang3.tuple.Pair<jakarta.mail.Store, jakarta.mail.Folder>> openFolder
(int mode) Opens a mail folder in the given mode.
-
Constructor Details
-
MailClient
public MailClient()
-
-
Method Details
-
openFolder
Optional<org.apache.commons.lang3.tuple.Pair<jakarta.mail.Store,jakarta.mail.Folder>> openFolder(int mode) throws jakarta.mail.MessagingException Opens a mail folder in the given mode.- Parameters:
mode
- see @Folder.open(int)
for available options.- Returns:
- pair of @
Store
and @Folder
if available. - Throws:
jakarta.mail.MessagingException
- if folder cannot be opened or store is inaccessible.
-
list
long list()Shows a list of messages in the mailbox root folder. It accesses the folder in read-only mode.- Returns:
- messages in given folder, -1 in case of errors.
-
delete
Application option to delete existing messages.- Returns:
- number of messages deleted, if any. Empty otherwise.
-
execute
Execute the given command or print an error message if the command is unknown.- Parameters:
command
- command to execute, should be one ofMailClient.MailClientCommands
.
-