Class MailpitClient
java.lang.Object
ch.martinelli.oss.testcontainers.mailpit.MailpitClient
Client for interacting with the Mailpit REST API.
Provides methods to retrieve, inspect, and delete caught email messages.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDeletes all messages from Mailpit.voiddeleteMessage(String id) Deletes a specific message.voiddeleteMessages(List<String> ids) Deletes specific messages by their IDs.Retrieves all messages from Mailpit.getMessage(String id) Retrieves a specific message by ID.intReturns the number of messages in Mailpit.getMessageHtml(String id) Retrieves the HTML body of a message.Retrieves the plain text body of a message.Retrieves the raw source of a message.
-
Constructor Details
-
MailpitClient
-
-
Method Details
-
getAllMessages
Retrieves all messages from Mailpit.- Returns:
- a list of all caught messages
- Throws:
MailpitException- if an error occurs while fetching messages
-
getMessageCount
public int getMessageCount()Returns the number of messages in Mailpit.- Returns:
- the message count
- Throws:
MailpitException- if an error occurs
-
getMessage
Retrieves a specific message by ID.- Parameters:
id- the message ID- Returns:
- the message details
- Throws:
MailpitException- if an error occurs or the message is not found
-
getMessageHtml
Retrieves the HTML body of a message.- Parameters:
id- the message ID- Returns:
- the HTML body, or null if not available
- Throws:
MailpitException- if an error occurs
-
getMessagePlain
Retrieves the plain text body of a message.- Parameters:
id- the message ID- Returns:
- the plain text body, or null if not available
- Throws:
MailpitException- if an error occurs
-
getMessageSource
Retrieves the raw source of a message.- Parameters:
id- the message ID- Returns:
- the raw message source
- Throws:
MailpitException- if an error occurs
-
deleteAllMessages
public void deleteAllMessages()Deletes all messages from Mailpit.- Throws:
MailpitException- if an error occurs
-
deleteMessages
Deletes specific messages by their IDs.- Parameters:
ids- the message IDs to delete- Throws:
MailpitException- if an error occurs
-
deleteMessage
Deletes a specific message.- Parameters:
id- the message ID to delete- Throws:
MailpitException- if an error occurs
-