Creates an instance of MailpitClient.
The base URL of the Mailpit API.
Optional
auth: { password: string; username: string }Optional authentication credentials.
The password for basic authentication.
The username for basic authentication.
Delete individual or all messages.
Optional
deleteRequest: MailpitDatabaseIDsRequestThe request containing the message database IDs to delete.
Plain text "ok" response
Delete all messages matching a search.
The search request containing the query.
Plain text "ok" response
Generates a cropped 180x120 JPEG thumbnail of an image attachment from a message. Only image attachments are supported.
Message database ID or "latest"
The attachment part ID
Image attachment thumbnail as binary data and the content type
Retrieves the current Chaos triggers configuration (if enabled).
The Chaos triggers configuration
Retrieves the configuration of the Mailpit web UI.
Configuration settings
Retrieves information about the Mailpit instance.
Basic runtime information, message totals and latest release version.
Retrieves a specific attachment from a message.
Message database ID or "latest"
The attachment part ID
Attachment as binary data and the content type
Retrieves the headers of a specific message.
The message database ID. Defaults to latest
to return the latest message.
Message headers
Retrieves a summary of a specific message and marks it as read.
The message database ID. Defaults to latest
to return the latest message.
Message summary
Performs an HTML check on a specific message.
The message database ID. Defaults to latest
to return the latest message.
The summary of the message HTML checker
Performs a link check on a specific message.
The message database ID. Defaults to latest
to return the latest message.
Whether to follow links. Defaults to false
.
The summary of the message Link checker.
Retrieves a list of message summaries ordered from newest to oldest.
The pagination offset. Defaults to 0
.
The number of messages to retrieve. Defaults to 50
.
A list of message summaries
getMessageSummary() for more attachment and body details for a specific message.
Release a message via a pre-configured external SMTP server.
The message database ID. Use latest
to return the latest message.
Array of email addresses to relay the message to
Plain text "ok" response
Renames an existing tag.
The current name of the tag.
A new name for the tag.
Plain text "ok" response
Renders the HTML part of a specific message which can be used for UI integration testing.
The message database ID. Defaults to latest
to return the latest message.
Optional
embed: 1Whether this route is to be embedded in an iframe. Defaults to undefined
. Set to 1
to embed.
The embed
parameter will add target="_blank"
and rel="noreferrer noopener"
to all links.
In addition, a small script will be added to the end of the document to post (postMessage()) the height of the document back to the parent window for optional iframe height resizing.
Note that this will also transform the message into a full HTML document (if it isn't already), so this option is useful for viewing but not programmatic testing.
Rendered HTML
Retrieve messages matching a search, sorted by received date (descending).
The search request containing the query and optional parameters.
A list of message summaries matching the search criteria.
Sends a message
The request containing the message details.
Response containing database messsage ID
Sets and/or resets the Chaos triggers configuration (if enabled).
The request containing the chaos triggers. Omitted triggers will reset to the default 0%
probabibility.
The updated Chaos triggers configuration
Set the read status of messages.
The request containing the message database IDs/search string and the read status.
Request parameters for the setReadStatus() API.
Optional
IDs?: string[]Array of message database IDs
Optional
Read?: booleanRead status
Optional
Search?: stringOptional
params: MailpitTimeZoneRequestOptional parameters for defining the time zone when using the before:
and after:
search filters.
Plain text "ok" response
You can optionally provide an array of IDs
OR a Search
filter. If neither is set then all messages are updated.
// Set all messages as unread
await mailpit.setReadStatus();
// Set all messages as read
await mailpit.setReadStatus({ Read: true });
// Set specific messages as read using IDs
await mailpit.setReadStatus({ IDs: ["1", "2", "3"], Read: true });
// Set specific messages as read using search
await mailpit.setReadStatus({ Search: "from:example.test", Read: true });
// Set specific messages as read using after: search with time zone
await mailpit.setReadStatus({ Search: "after:2025-04-30", Read: true }, { tz: "America/Chicago" });
Sets and removes tag(s) on message(s). This will overwrite any existing tags for selected message database IDs.
The request containing the message IDs and tags. To remove all tags from a message, pass an empty Tags
array or exclude Tags
entirely.
Plain text "ok" response
Performs a SpamAssassin check (if enabled) on a specific message.
The message database ID. Defaults to latest
to return the latest message.
The SpamAssassin summary (if enabled)
Client for interacting with the Mailpit API.
Example