Class Mailbox


  • public class Mailbox
    extends Object
    Injected MailContext wrapping the API to Mailpit for unit testing.
    • Constructor Detail

      • Mailbox

        public Mailbox()
    • Method Detail

      • delete

        public void delete​(String ID)
                    throws ApiException
        Delete a single message.
        Parameters:
        ID - Database ID to delete
        Throws:
        ApiException - if fails to make API call
      • find

        public List<Message> find​(String query,
                                  Integer start,
                                  Integer limit)
                           throws ApiException
        Search messages. Returns the latest messages matching a search.
        Parameters:
        query - Search query (required)
        start - Pagination offset (optional, default to 0)
        limit - Limit results (optional, default to 50)
        Returns:
        List
        Throws:
        ApiException - if fails to make API call
      • findFirst

        public Message findFirst​(String query)
                          throws ApiException
        Search messages. Returns the first message matching a search.
        Parameters:
        query - Search query (required)
        Returns:
        Message
        Throws:
        ApiException - if fails to make API call
      • getApplicationInfo

        public AppInformation getApplicationInfo()
                                          throws ApiException
        Get application information Returns basic runtime information, message totals and latest release version.
        Returns:
        AppInformation
        Throws:
        ApiException - if fails to make API call
      • getApiClient

        public ApiClient getApiClient()
      • getMessageApi

        public MessageApi getMessageApi()
      • createApiClient

        public ApiClient createApiClient()
      • getMailApiUrl

        public String getMailApiUrl()
        Use "mailpit.http.server" to get the running Mailpit API Server.
        Returns:
        the mailer URL or an exception if not found
      • createDefaultObjectMapper

        public com.fasterxml.jackson.databind.ObjectMapper createDefaultObjectMapper()
        Create the JSON Mapper with some defaults and custom LocalDateTime parsing.
        Returns:
        the ObjectMapper