Class MailClient

java.lang.Object
de.aikiit.mailclena.mail.MailClient

public final class MailClient extends Object
Encapsulates technical access to mail inbox based on the given application/mail configuration.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    (package private) static enum 
    Encapsulates available application commands for MailClena.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) Optional<Long>
    Application option to delete existing messages.
    void
    execute(String command)
    Execute the given command or print an error message if the command is unknown.
    (package private) long
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      Optional<Long> delete()
      Application option to delete existing messages.
      Returns:
      number of messages deleted, if any. Empty otherwise.
    • execute

      public void execute(String command)
      Execute the given command or print an error message if the command is unknown.
      Parameters:
      command - command to execute, should be one of MailClient.MailClientCommands.