Package io.jmix.imap

Interface ImapManager

All Known Implementing Classes:
ImapManagerImpl

public interface ImapManager
Gateway for E-mail servers communication via IMAP protocol
Provides operations for
  • IMAP mailbox (in terms of IMAP it is server) folders (in terms of IMAP it is mailbox) retrieval
  • Messages retrieval
  • Messages modification

Connection details for mailbox are specified in ImapMailBox object.
Folder is uniquely defined by its mailbox and full name (considering tree structure of folders), it is represented by ImapFolder object
Message is uniquely defined by its folder and UID, it is represented by ImapMessage object, UID is specified in ImapMessage.getMsgUid() property
  • Method Details

    • testConnection

      ImapConnectResult testConnection(ImapMailBox box)
      Check a connection for specified mail box
      Parameters:
      box - mail box to connect
      Returns:
      result of set connection
    • fetchFolders

      Collection<ImapFolderDto> fetchFolders(ImapMailBox mailBox)
      Retrieve all folders of mailbox preserving tree structure
      Parameters:
      mailBox - IMAP mailbox connection details
      Returns:
      root folders of IMAP mailbox, each folder can contain nested child folders forming tree structure
    • fetchFolders

      List<ImapFolderDto> fetchFolders(ImapMailBox mailBox, String... folderNames)
      Retrieve folders of mailbox with specified full names, result is presented in flat structure hiding parent\child relationship
      Parameters:
      mailBox - IMAP mailbox connection details
      folderNames - full names of folders to retrieve
      Returns:
      folders of IMAP mailbox with specified full names, result is ordered according to order of names input
    • fetchMessage

      ImapMessageDto fetchMessage(ImapMessage message)
      Retrieve single message
      Parameters:
      message - reference object for IMAP message
      Returns:
      fully fetched message or null if there is no message with such UID in corresponding folder
      Throws:
      ImapException - if wrong folder or mailbox connection details are specified in parameter
    • moveMessage

      void moveMessage(ImapMessage message, String folderName)
      Move message in different folder, if folder is the same - nothing changed, if folder with specified full name doesn't exist - results in throwing ImapException
      Parameters:
      message - reference object for IMAP message
      folderName - full name of new folder
      Throws:
      ImapException - for wrong folder
    • deleteMessage

      void deleteMessage(ImapMessage message)
      Delete message
      Parameters:
      message - reference object for IMAP message
    • setFlag

      void setFlag(ImapMessage message, ImapFlag flag, boolean set)
      Change meta data flag for message, flag can be either standard or custom one
      Parameters:
      message - reference object for IMAP message
      flag - flag to change
      set - if true - set the flag, if false - clear the flag